Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3815

public GroovyCodeSource(String script, String name, String codeBase) cripples script code with some UTF-8 characters (e.g. Japanese)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.7.0
    • class generator
    • None
    • Any environment

    Description

      When creating Groovy objects from String via GroovyClassLoader, e.g. like in GStringTemplateEngine , the Constructor of GroovyCodeSource(String script, String name, String codeBase) translates all UTF-8 Chars with a value > 0xFF into '?'.

      You can see this in the GroovyConsole aswell:
      Run the script
      println "こんにちは"
      and you will see the correct sourcecode in the first line, but the output is ?????

      Or in Java code:
      loader.parseClass(new GroovyCodeSource("println 'こんにちは';", "TestScript", "x");

      The line
      new ByteArrayInputStream(script.getBytes()))
      cripples them down to byte values.

      I worked around it by while creating my script I escape character > 0xFF with the /u-Notation like /u1234 but this is not always possible as in the Groovy console.

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            karfunkel Alexander Klein
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: