应用程序中的Unicode字符无法正确显示 [英] Unicode characters in app doesn't show correctly
问题描述
如何将字符串转换为例如BohinjskaČešnjica
。我从网站获得的字符串,它不是编码在 unicode
中。它在使用swing( Netbeans
)的程序中工作得很好,但当我通过链接到jar到windows控制台(运行 jframe
应用程序)在字符串BohinjskaČešnjica中不显示正确的字符
'Č'
和'š'
。
字符串示例=BohinjskaČešnjica;
我从网站获得该字符串。
如何在Swing应用程序中编码或显示为(BohinjskaČešnjica)
,所以当我运行一个 jframe
应用程序它会显示我这个字符(和其他unicode characters of ofcourse('Ž','ž','č'和'Š'))?
链接1:我的程序的jar文件从控制台运行
链接2:当我从NetBeans运行程序
从网站读取内容:
nov =新网址(http://www.arso.gov.si/vreme/napovedi%20in%20podatki/vreme_avt.html);
URLConnection conn = nov.openConnection(); //连接到一个网站
BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuilder niz = new StringBuilder(); ((inputLine = br.readLine())!= null){
String vrstica = inputLine.trim(); //阅读html ...
}
新的BufferedReader(
new InputStreamReader
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";
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 'Š'))?
Link 1 :jar file of my program runned from console Link 2:when i run program from netbeans
READING CONTENT FROM WEBSITE :
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"));
这篇关于应用程序中的Unicode字符无法正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!