从System.in获取Unicode值 [英] Getting unicode values from System.in
本文介绍了从System.in获取Unicode值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个Scanner
,它从System.in
获取输入,以便可以从控制台获取输入.
I have created a Scanner
that gets input from System.in
so that I can get input from the console.
Scanner scanner = new Scanner(System.in, "UTF-8");
当我这样做
String s = scanner.next();
,然后在控制台中输入Слово דבר
,字符串的值将变为???? ???
.
and then input Слово דבר
in the console, the value of the string becomes ???? ???
.
控制台能够显示Unicode字符,但是为什么我看不到它们?
The console is able to display Unicode characters, but why can't I read them?
推荐答案
假定System.in
是UTF-8编码是不安全的.有关某些解决方法,请参见此问题.
It's not safe to assume System.in
is UTF-8 encoded. See this question for some workarounds.
这篇关于从System.in获取Unicode值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文