« Return to Thread: Changing non-standard ASCII character casing (UTF-8)

Re: Changing non-standard ASCII character casing (UTF-8)

by Matthew Ueckerman :: Rate this Message:

Reply to Author | View in Thread

Fortunately I've discovered a way to do this.  Unfortunately it requires explicit use of Java.

>> s = "Café"
=> "Café"
>> s.upcase
=> "CAFé"
>> s.to_java_string.to_upper_case
=> "CAFé"
>> java.lang.String.new(s).to_upper_case
=> "CAFÉ"

It's intriguing that converting from a Ruby to a Java String does not behave the same way as creating a Java String.
Furthermore;

>> s.to_java_string.to_s
=> "Café"

Suggests that the encoding of the converted String is incorrect.

Regards,

Matthew Ueckerman

Matthew Ueckerman wrote:
I'm looking for some information on changing the casing of non-standard ASCII UTF-8 characters in JRuby.

In MRI, it appears the unicode gem is the recommended approach for this:
http://ideaharbor.org/notes/technical/working-with-unicode-in-ruby/

Is there a recommended approach in JRuby?

Matthew

 « Return to Thread: Changing non-standard ASCII character casing (UTF-8)