Unicode characters are lost when embedding JRuby even if the calling code performs no conversion to byte[] ----------------------------------------------------------------------------------------------------------
Key: JRUBY-4890 URL: http://jira.codehaus.org/browse/JRUBY-4890 Project: JRuby Issue Type: Bug Affects Versions: JRuby 1.5.1 Reporter: Trejkaz Assignee: Thomas E Enebo The following tests fail on JRuby 1.5.1 if file.encoding is set to any value which cannot encode Japanese characters (we discovered it with windows-1252.) The Unicode characters present in the original script become "?????". As the script itself is already a string and the code embedding it never converts to a byte[], I believe that there should be no reason for it to convert anything to the default encoding. {code:java} public class TestUnicodeCharacters { String orig = "\u3070\u304B\u3084\u308D\u3046"; String scriptlet = "str = \"" + orig + "\" ; puts str ; str"; Writer writer = new StringWriter(); @Test public void testCharacterEncodingViaScriptEngine() throws Exception { ScriptEngine engine = new ScriptEngineManager().getEngineByExtension("rb"); ScriptContext context = engine.getContext(); context.setWriter(writer); String result = (String) engine.eval(scriptlet, context); checkValues(result); } @Test public void testCharacterEncodingViaScriptContainer() throws Exception { ScriptingContainer container = new ScriptingContainer(); container.setWriter(writer); // The next lines don't help anyway, but I half expected them to... //container.setCompatVersion(CompatVersion.RUBY1_9); //container.setKCode(KCode.UTF8); String result = (String) container.runScriptlet(scriptlet); checkValues(result); } private void checkValues(String returnedResult) { assertEquals("Wrong result returned", orig, returnedResult); assertEquals("Wrong result printed", orig, writer.toString().trim()); } } {code} -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email