JRuby

Error in string encoding conversion

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major 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 :
    0

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.

Activity

Hide
Charles Oliver Nutter added a comment -

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.

Show
Charles Oliver Nutter added a comment - 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.
Hide
Charles Oliver Nutter added a comment -

Fixed in r8924.

Show
Charles Oliver Nutter added a comment - Fixed in r8924.
Hide
Ricardo Trindade added a comment -

I can confirm that this does fix the above issue.

Show
Ricardo Trindade added a comment - I can confirm that this does fix the above issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: