应用程序中的 Unicode 字符显示不正确 [英] Unicode characters in app doesn't show correctly
问题描述
如何转换这样的字符串,例如 "Bohinjska Češnjica"
.我从网站上得到的字符串,它不是用 unicode
编码的.它在使用 Swing(Netbeans
) 的程序中运行良好,但是当我将 jar 的链接传递到 Windows 控制台(运行 jframe
应用程序)时,它显示不正确字符串 "Bohinjska Češnjica"
中的字符,用于字符 'Č'
和 'š'
.
How to convert string like that for example "Bohinjska Češnjica"
. The string that I get from the website and it is not encoded in unicode
. It works just fine in program that uses swing(Netbeans
), but when I past the link to jar to windows console(to run jframe
application) it doesn't show correct characters in the string "Bohinjska Češnjica"
for characters 'Č'
and 'š'
.
String example="Bohinjska Češnjica";
我从网站上获得该字符串.我如何在 Swing 应用程序中编码或显示它是 ("Bohinjska Češnjica")
,所以当我运行 jframe
应用程序时,它会向我显示这些字符(和其他unicode字符ofcourse('Ž','ž','č'和'Š'))?
I get that string from website.
How do I encode or show as it is ("Bohinjska Češnjica")
in a Swing application, so when i will run a jframe
application it will show me this characters(and others unicode characters ofcourse ('Ž','ž','č' and 'Š'))?
链接 1:从控制台运行的我的程序的 jar 文件链接 2:当我从 netbeans 运行程序时
从网站上阅读内容 :
URL nov = new URL("http://www.arso.gov.si/vreme/napovedi%20in%20podatki/vreme_avt.html");
URLConnection conn = nov.openConnection(); //connect to a website
BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuilder niz = new StringBuilder();
while ((inputLine = br.readLine()) != null) {
String vrstica = inputLine.trim(); //reading html...
}
推荐答案
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
BufferedReader br = new BufferedReader( new InputStreamReader(conn.getInputStream(), "UTF-8"));
这篇关于应用程序中的 Unicode 字符显示不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!