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

Inconsistency between CompilerConfiguration, groovy -c and groovysh ?

    XMLWordPrintableJSON

Details

    Description

      Given the following script, saved as enc_test.groovy

      import org.codehaus.groovy.control.CompilerConfiguration
      println "File source encoding is probably set to " + CompilerConfiguration.DEFAULT.getSourceEncoding()
      

      I would assume all three executions below to print "UTF-8", but they don't:

      $ groovy -c UTF-8 enc_test.groovy
      File source encoding is probably set to MacRoman
      
      $ groovy -Dgroovy.source.encoding=UTF-8 enc_test.groovy
      File source encoding is probably set to MacRoman
      
      $ groovysh -Dgroovy.source.encoding=UTF-8
      groovy:000> org.codehaus.groovy.control.CompilerConfiguration.DEFAULT.getSourceEncoding()
      ===> UTF-8
      

      The reason I was printing this info was to track down an encoding issue I had; turns out the -c flag actually works for me (i.e my sources are properly decoded) (while the -Dgroovy.source.encoding option doesn't), but I was looking for a way to ensure my scripts are executed with -c UTF-8, but the above snippet obviously doesn't help.

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            gjoseph Grégory Joseph
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: