Question

I would like to output floral formulae by my DSL in groovy, so I need some special symbols such as female sign and Superscripts and Subscripts.

The question is about the Eclipse IDE (Groovy/Grails Tool Suite Version: 3.1.0.RELEASE to develop a grails project) and Groovy console (GroovyStarter)

given this sample groovy statement:

println '♀ Ca\u2075'

I get the expected output in terminal if I run the program from the terminal:

$ groovy Testformula.groovy   
♀ Ca⁵

The same is OK if I run it from the Groovy/Grails Tool Suite as a Java application but if I eighter run it as a Groovy script or in the Groovy console (Groovy starter) I get question mark instead of unicode symbols:

groovy> package org.rondakit.test 
groovy> class Testformula { 
groovy>     static void main(def args) { 
groovy>         println '\u2640' 
groovy>         println '♀ Ca\u2075' 
groovy>     } 
groovy> } 

I get the nasty result:

?
? Ca?

Question: is it possible to configure GroovyStarter or the Groovy Console on GGTS to display unicode symbols?

Was it helpful?

Solution 2

It works fine in my box (ubuntu 12.04) under GGTS using "Run as..." either Groovy Console or Groovy Script. You may want to check configuration in your ggts.

Windows by default runs on cp1252 encoding (we had some troubles with source on wrong encoding in some projects this year). Linux by default is utf-8. I'm not sure about OS X

OTHER TIPS

I found the solution for groovyConsole, You need to put "export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8" to environment variable

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top