Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

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

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