Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode characters are lost when embedding JRuby using ScriptContainer #4682

Open
hakanai opened this issue Jun 23, 2017 · 1 comment
Open

Comments

@hakanai
Copy link

hakanai commented Jun 23, 2017

Environment

  • JRuby 9.1.12.0
  • Windows only? Not sure. Definitely fails on Windows, but all our non-Windows machines have file.encoding set to UTF-8.
  • file.encoding = windows-1252

Test Case

    private static final String ORIG = "\u6625\u304C\u6765\u305F\u3002";
    private static final String SCRIPTLET = "#encoding: UTF-8\n" +
                                            "str = \"" + ORIG + "\"\n" +
                                            "puts str\n" +
                                            "str\n";
    @Test
    public void testCharacterEncodingViaScriptContainer() throws Exception
    {
        // Regression test for https://github.com/jruby/jruby/issues/2403

        ScriptingContainer container = new ScriptingContainer();
        container.setWriter(writer);
        String result = (String) container.runScriptlet(SCRIPTLET);
        checkValues(result);
    }

    private void checkValues(String returnedResult)
    {
        assertThat(returnedResult, is(equalTo(ORIG)));
        assertThat(writer.toString().trim(), is(equalTo(ORIG)));
    }

Actual Behaviour

The equivalent test using ScriptEngine passes, but this test fails:

java.lang.AssertionError: 
Expected: is "春が来た。"
     but: was "春���。"

This is super low priority since we only actually use ScriptEngine, but I thought it might be worth reporting anyway.

@hakanai
Copy link
Author

hakanai commented Jun 23, 2017

(Sorry about the weird partial submission followed by an edit - GitHub somehow submitted the form even though the mouse was nowhere near the button and I definitely hadn't hit the key combination required to submit it that way either...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant