Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7.5
-
Fix Version/s: 1.7.6, 1.8-beta-3
-
Component/s: command line processing, Compiler, Groovysh
-
Labels:None
-
Number of attachments :
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.