in groovy println “£” gives £, in gradle println “£” gives ┬ú has anyone else seen this?
You need to make sure your VM is running with an encoding that supports that character.
You can do this by setting JAVA_OPTS or GRADLE_OPTS to ‘-Dfile.encoding=utf8’.
I can change the encoding to suit, the reason I point it out is that I shouldn’t have to when groovy in the same environment works fine ‘out of the box’
I am just pointing out the possibility that the initial user experience could be better
Groovy doesn’t do anything different here. It doesn’t set this automatically.
Are you running both with the same environment vars and Java version?
Both Gradle and Groovy report System.properties[‘file.encoding’] = Cp1252 I am running in the same command line and java version is 1.7.0_13 as reported by ‘java -version’ and ‘System.properties[‘java.version’]’ from both groovy and gradle.
Yet println “£” works in groovy but not gradle
are there any other environment checks I could do because it really looks to me like a gradle bug
How are you executing the Groovy code?
I was just using groovysh as a quick test, however since you’ve asked the question I’ve now tried "groovy -e “println ‘£’” and that didn’t print the character properly either.
So it’s groovysh that’s configuring something, although it’s not the file.encoding option?!?!
Sorry for implying the experience of gradle was less than groovy out of the box
I think I know what’s happening…
When you’re in the shell there’s no encoding mismatch as it’s all happening in the JVM. In other cases though there is.
No problems at all. Important to work through these things.