2

I'd like to do this:

System.out.println("안녕하세요!");

But I get a "Some characters could not be encoded using the MacRoman character encoding" popup error message when I try to compile in Eclipse. I'm running Mac OS X. Is there a way to get around that?

So, I guess I'll try using Unicode:

System.out.println((char)0xD0A4);

Which I'd like to print out '키', but instead get a '?'. I guess the command line doesn't support Unicode. But even if it did, it'd be really annoying to have to go to one of several charts (like this one) to find each character block.

Anyway, FINE! So I'll use a JLabel...

JLabel lbl = new JLabel(""+(char)0xD0A4);

Awesome, this prints out 키! ... but I still have to look up the Unicode characters for each block. How can I easily spew out Korean characters in a program?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Robz
  • 1,747
  • 5
  • 21
  • 35
  • This [link](http://hints.macworld.com/article.php?story=20050208053951714) might be of help! – CoolBeans Jun 17 '11 at 04:45
  • Which terminal program are you using? Which encodings have you enabled it to use - Preferences / Encodings)? I use /Applications/Utilities/Terminal and have a variety of encodings enabled, including UTF-8 (and MacRoman, and Korean EUC). – Jonathan Leffler Jun 17 '11 at 04:56

3 Answers3

5

Switch to UTF-8, as said before. However, instead of doing it on a per-project basis (as J-16) suggests, go through Window -> Preferences -> General -> Workspace and change the "Text file encoding" to "Other: UTF-8".

This changes the setting for the entire workspace. Afterwards, you can input your characters as you are used to.

Urs Reupke
  • 6,791
  • 3
  • 35
  • 49
  • 1
    Make sure that you back up everything beforehand. When you do this, you can expect all of your non-ASCII characters to become garbled. Pasting them in from another source AFTER switching encodings is fine. –  Jun 17 '11 at 05:42
  • Yes, bdares, that is a very helpful suggestion. – Urs Reupke Jun 17 '11 at 05:55
  • I am trying to print korean currency symbol in a downloaded csv file. It always replaces the currency symbol with '?'. Any idea? – Developer Apr 18 '23 at 16:45
1

The Eclipse console doesn't use unicode encoding so it can't display those. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=13865.

Try the fix mentioned here: http://paranoid-engineering.blogspot.com/2008/05/getting-unicode-output-in-eclipse.html

kevmo314
  • 4,223
  • 4
  • 32
  • 43
1

Just right click the file in the project view, choose properties. Change the encoding to UTF8 there.

J-16 SDiZ
  • 26,473
  • 4
  • 65
  • 84