I am trying to catch the Chinese Characters from Scanner.
I am running in cmd.exe on Windows 10.
I've already run CHCP 65001.
here is the code.
import java.util.Scanner;
public class JavaScannerCN
{
public static void main (String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.print("中文 user name: ");
String username = scanner.next();
scanner.close();
System.out.println(String.format("Hello, %s", username));
System.out.println((int)'中');
System.out.println((int)username.charAt(0));
}
}
thanks to @ParkerHalo reminder, it seems the character received has been damaged, since the output is
Hello, ��
20013
96
This code outputs the Chinese Characters that's inside code properly, while outputs the Chinese Characters catched from Scanner as junk.
How to fix that?