Arv*_*ind 3 java eclipse utf-8 character-encoding thai
当我在控制台中打印泰国字符时,它显示出一些奇怪的特征.
public static void main(String[] args) throws Exception{
byte[] bytes = "???????".getBytes("TIS-620");
String str = new String(bytes);
System.out.println(str);
}
Run Code Online (Sandbox Code Playgroud)
它打印 ¢
假设您在Windows中使用eclipse,在控制台中启用UTF-8(假设您的IDE能够使用UTF-8编码Windows -> Preferences -> General -> Workspace -> Test File Encoding = UTF-8):
Windows -> Preferences -> Java -> Installed JREs,选择JRE和编辑.添加-Dfile.encoding=UTF-8到默认VM参数(或者您可以编辑您的eclipse.ini并添加此参数,但它对我不起作用)
Windows -> Preferences -> General -> Appearence -> Debug -> Console Font选择Arial,Calibri等)
码:
public static void main(String[] args) throws Exception {
byte[] bytes = "???????".getBytes();
String str = new String(bytes);
System.out.println(str);
}
Run Code Online (Sandbox Code Playgroud)
正如评论中指出的那样,简单的字符串打印
System.out.println("???????");
Run Code Online (Sandbox Code Playgroud)
输出:
ฝ่ายขาย