Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.2
-
Fix Version/s: JRuby 1.2
-
Component/s: Java Integration
-
Labels:None
-
Environment:trunk, windows vista, jdk 1.6.0_11
-
Number of attachments :
Description
I just noticed that the following doesn't work properly. Could it be that there's an encoding conversion missing when calling to_s on a ruby object ?
def createFrame(component = nil, frame_title = "Teste")
frame = javax.swing.JFrame.new(frame_title)
frame.contentPane.setLayout(java.awt.BorderLayout.new)
frame.contentPane.add(component) unless component == nil
frame.setSize( 400,300 )
frame.show()
frame
end
class TestClass
def to_s
"çáÈão"
end
end
createFrame(javax.swing.JComboBox.new([TestClass.new, TestClass.new].to_java))
This was supposed to show the characters in to_s in a combo box, but instead shows the wrong characters.
I have a fix coming that basically makes the default RubyObject.toString work like Java Integration...now it take the to_s result and convert it using UTF-8.
I feel a pending dread for the day when we realize that we can't always assume UTF-8, but we'll cross that bridge when we come to it. Doing it the same as JI should be correct for now.
Commit coming.