groovy

getting character encoding from command line is failed

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0
  • Fix Version/s: 1.1-beta-2
  • Component/s: None
  • Labels:
    None
  • Environment:
  • Number of attachments :
    1

Description

I wrote a groovy script like,

----HelloUtf8.groovy (saved with UTF8)
println "こんにちは";


then, executed this and it resulted like,


$ groovy -c UTF8 HelloUtf8.groovy
Caught: BUG! exception in phase 'parsing' in source unit 'HelloUtf8.groovy' char
setName


so, I checked "GROOVY_1_0/src/main/groovy/ui/GroovyMain.java"
where getting encoding from command line.


@@ -241,7 +244,9 @@

// add the ability to parse scripts with a specified encoding
if (line.hasOption('c')) { - main.conf.setSourceEncoding(line.getOptionValue("encoding")); + main.conf.setSourceEncoding(line.getOptionValue('c')); + System.out.println("GroovyMain:encoding:" + + main.conf.getSourceEncoding()); }


It's found that 'main.conf.setSourceEncoding(line.getOptionValue("encoding"))' returned null,
and 'main.conf.setSourceEncoding(line.getOptionValue('c'))' returned "UTF-8".

Activity

Hide
Hiroki Taira added a comment -

sorry. following statements are not collect.

It's found that 'main.conf.setSourceEncoding(line.getOptionValue("encoding"))' returned null,
and 'main.conf.setSourceEncoding(line.getOptionValue('c'))' returned "UTF-8".

they have to be fixed ,

It was found that 'line.getOptionValue("encoding")' returned null,
and 'line.getOptionValue('c')' returned "UTF-8".

Show
Hiroki Taira added a comment - sorry. following statements are not collect. It's found that 'main.conf.setSourceEncoding(line.getOptionValue("encoding"))' returned null, and 'main.conf.setSourceEncoding(line.getOptionValue('c'))' returned "UTF-8". they have to be fixed , It was found that 'line.getOptionValue("encoding")' returned null, and 'line.getOptionValue('c')' returned "UTF-8".
Hide
blackdrag blackdrag added a comment -

should be fixed now... I had strange problem with the encoding options... on linux --encoding=UTF8 was correctly recognized, on windows groovy thought I wanted to open a file named UTF8. But this seems not to be a bug in Groovy, but in commons-cli.

Anyway I got it working by doing the following:

  • I set the file.encoding property to UTF8
  • I started groovy with 'groovy --encoding=UTF8 HelloUtf8.groovy > out.txt'
  • I used Firefox to view out.txt and set the encoding to UTF8 to verify the characters there look like these in HelloUtf8.groovy

If you wonder why I do it that complicated... it is really like hell telling windows to use UTF8 correctly on the console. In the end I gave up, because I found no font displaying japanese characters. I have one for chinese using the encoding gb2312, but that's no of much help here. It was much more easy using Firefox.

So I mark it as fixed for now

Show
blackdrag blackdrag added a comment - should be fixed now... I had strange problem with the encoding options... on linux --encoding=UTF8 was correctly recognized, on windows groovy thought I wanted to open a file named UTF8. But this seems not to be a bug in Groovy, but in commons-cli. Anyway I got it working by doing the following:
  • I set the file.encoding property to UTF8
  • I started groovy with 'groovy --encoding=UTF8 HelloUtf8.groovy > out.txt'
  • I used Firefox to view out.txt and set the encoding to UTF8 to verify the characters there look like these in HelloUtf8.groovy
If you wonder why I do it that complicated... it is really like hell telling windows to use UTF8 correctly on the console. In the end I gave up, because I found no font displaying japanese characters. I have one for chinese using the encoding gb2312, but that's no of much help here. It was much more easy using Firefox. So I mark it as fixed for now

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: