Unexpected ASCII-8BIT encoding of jruby --1.9 converted java strings

Hello,

can somebody tell me if it is intended that Java strings converted to
Ruby string have the encoding ASCII-8BIT? I expected to be something
like UTF-16 or UTF-8, since Java internally uses UTF-16 encoding.


$ jruby --1.9 --version
jruby 1.6.0 (ruby 1.9.2 patchlevel 136) (2011-03-15 f3b6154) (Java
HotSpot™ Client VM 1.6.0_24) [Windows XP-x86-java]

$ jruby --1.9 -e “require ‘java’; s =
java.lang.Character.new(228).toString; puts s.inspect, s.size,
s.encoding”
“\xC3\xA4”
2
ASCII-8BIT

The expected result would be a string containing the character ä (a
diaresis) encoded in UTF-8. The output shows that JRuby converts to
UTF-8, but fails to set the correct encoding. Feeding the result string
back to Java garbles the string to uselessness.

Using ASCII-8BIT as encoding for strings converted from Java makes
JRuby/Java combinations useless in 1.9 mode.

this is resolved on HEAD

http://jira.codehaus.org/browse/JRUBY-5646

regards ,Kristian