Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7168947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:53:07+00:00 2026-05-28T14:53:07+00:00

Trying to debug an issue with saving multicharacter data to the database, I narrowed

  • 0

Trying to debug an issue with saving multicharacter data to the database, I narrowed down the issue to how Groovy is handling my strings.
I have this snippet of code:

println "Hi!"
def strings=[
 "Dies ist eine Testlinie in deutscher Sprache.",
 "C'est une ligne d'essai en français.",
 "Is é seo an líne tástála i nGaeilge..",
 "Esta é unha liña de proba en galego.",
 "Questa è una linea di prova in italiano.",
 "Dette er en test linje i norsk.",
 "Þetta er próf lína í íslensku.",
 "Góðan dag, hvernig ert þú að gera?",
 "Ich komme aus Köln"
]
strings.each {
  println it
}

I saved this snippet copying the lines from my browser into the GroovyConsole.

If I run it on the Windows command line with:

groovy testAnsi.groovy

I get:

Hi!
Dies ist eine Testlinie in deutscher Sprache.
C'est une ligne d'essai en franτais.
Is Θ seo an lφne tßstßla i nGaeilge..
Esta Θ unha li±a de proba en galego.
Questa Φ una linea di prova in italiano.
Dette er en test linje i norsk.
▐etta er pr≤f lφna φ φslensku.
G≤≡an dag, hvernig ert ■· a≡ gera?
Ich komme aus K÷ln

If I open the file with Notepad++, it says it’s written in ANSI and shows lots of odd characters.
If I open it with Notepad, it says it’s written in ANSI and shows the proper characters.

If I then save the file with Notepad in Unicode (it shows as UC2 Little Endian with all the proper characters in Notepad++), and run it on the command line as:

groovy -c UTF-16 testUnicode.groovy

I get this:

Hi!
Dies ist eine Testlinie in deutscher Sprache.
C'est une ligne d'essai en franτais.
Is Θ seo an lφne tßstßla i nGaeilge..
Esta Θ unha li±a de proba en galego.
Questa Φ una linea di prova in italiano.
Dette er en test linje i norsk.
▐etta er pr≤f lφna φ φslensku.
G≤≡an dag, hvernig ert ■· a≡ gera?
Ich komme aus K÷ln

But when I run either the ANSI or Unicode file within the GroovyConsole, I get the expected results in the output panel.

Now, if I do:

more testAnsi.groovy

I get the same gibberish I get if I would run the script.

If I do:

more testUnicode.groovy

I get proper characters, except for the Icelandic ones.

Note, I get the same exact results if I run the code on a Linux box, but when using cat to display the content of the source files, I always get the proper characters.

I am stumped. Clearly I’m doing something wrong, but I don’t know what.

How do I get Groovy to output the characters that are in my strings, just as I have them in the file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:53:07+00:00Added an answer on May 28, 2026 at 2:53 pm

    Groovy is outputting in the Java default character set, which for your platform is code page 1252 (Western European “ANSI”). However the results are being displayed in code page 437 the old DOS “OEM” code page.

    You may be able to fix this by typing:

    chcp 1252
    

    in the command prompt before running Groovy. Naturally the output of the program will have to fit within that code page, so you can use the Western European accents in your example but you won’t be able to write any other alphabets.

    For testing Unicode behaviour you would be well advised to avoid the Windows command prompt like the plague.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to debug an issue. We have few Threads that work on data
I've been trying to debug this issue for weeks now and I have made
I am trying to debug a strange issue with users that have LogMeIn installed.
I'm trying to debug an issue that is really stumping me. Basically, I have
So here I am trying to debug this issue where the program takes forever
I have an issue I'm trying to debug, and normally I would use Firebug's
So ive been trying to debug this friggin spacing issue for the last 4
I've been trying to debug an issue and I pinned pointed it down to
I've been trying to debug this issue for hours upon hours but with no
Trying to debug an issue with a server and my only log file is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.