Code:
Scanner sc = new Scanner(System.in);
System.out.println("Enter Name : ");
String name = sc.nextLine();
System.out.println(name);
String encoding = "UTF-8";
System.out.println(new String(name.getBytes(encoding), "euc-jp"));
System.out.println(new String(name.getBytes(encoding), "Shift_JIS"));
System.out.println(new String(name.getBytes(encoding), "ISO-2022-JP"));
System.out.println(new String(name.getBytes(encoding), "ISO8859-1"));
Input:
Enter Name : たなかです
Output:
�F�Q���N�@
鐃�鐃�鐃緒申鐃�鐃�
�ソスF�ソスQ�ソス�ソス�ソスN�ソス@
���F���Q���������N���@
�F�Q���N�@
None of them are readable Japanese.
I've also tried InputStreamReader
and DataInputStream
with Byte[]
.