Reputation: 75
I'm using the Scanner
class as follows:
Scanner sc = new Scanner(System.in);
System.out.println(sc.nextLine());
It works ok, but if the input contains utf-8 characters the console cannot read them.
So how can I get utf-8 characters from the keyboard or set input without utf-8
Thanks so much.
Upvotes: 1
Views: 348
Reputation: 15209
Try specifying the encoding and locale:
Locale locale = new Locale("vi" , "VN");
Scanner sc = new Scanner(System.in, "UTF-8");
sc.useLocale(locale);
System.out.println(sc.nextLine());
Upvotes: 1