What encoding I should use in editor (NetBeans), if I were intend to print non-english character
Posted
by Yan Cheng CHEOK
on Stack Overflow
See other posts from Stack Overflow
or by Yan Cheng CHEOK
Published on 2010-06-11T02:03:13Z
Indexed on
2010/06/11
2:13 UTC
Read the original article
Hit count: 391
java
I try to set the encoding of my editor to UTF-16. (Java String store the data in UTF-16 internally, right?)
And I type the following code
package helloworld;
/**
*
* @author yan-cheng.cheok
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("???");
System.out.println("\u6587\u4EF6\u79CD\u7C7B");
}
}
However, the output is not what I expected :
????
?????
I try to change the editor encoding format to UTF-8, it works this time!
???
????
May I know why I need to change the editor encoding format to UTF-8 but not UTF-16? Isn't Java String store the data in UTF-16 internally?
© Stack Overflow or respective owner