Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print [Simplified] Chinese characters to Eclipse console?

I have the following code:

import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.Locale;

public final class ChineseCharacterDemo {

    public static void main(String[] args) throws UnsupportedEncodingException {
        Locale locale = new Locale("zh", "CN");
        System.out.println(locale.getDisplayLanguage(Locale.SIMPLIFIED_CHINESE));
    }

}

And even after setting the character encoding of the Eclipse console to UTF-8, I get boxes, instead of the following:

中文

What am I doing wrong?


EDIT-

After changing the Eclipse console font to something capable of rendering Chinese characters, I get the following, incorrect, display:

enter image description here

But, when I copy/paste the text here, it correctly renders the Simplified Chinese text. Again, what's going on here? Actually, if you look at the rendered text in the console, it's the correct characters, but they're on their side!


Resolution-

So, it turns out that I needed to do the following:

  1. Change character encoding of Eclipse console to UTF-8
  2. Change font to Arial Unicode MS (i.e. any font capable of rendering Chinese text)
like image 685
mre Avatar asked Nov 08 '11 20:11

mre


People also ask

How do I print text in eclipse?

You select the text in your console, right-click and select copy. Now you can paste the text you've copied. Show activity on this post. Your function may be using System.

How do I display Japanese characters in Eclipse?

You can set that by Window > Preferences > General > Workspace > Text File Encoding.


1 Answers

Change the font for the Console to one which actually contains the Chinese characters you need to see.

like image 93
Thorbjørn Ravn Andersen Avatar answered Sep 22 '22 17:09

Thorbjørn Ravn Andersen