如何将字符串转换为例如"Bohinjska Češnjica"
。我从网站获得的字符串,它不在unicode
中编码。它在使用swing的程序中工作得很好(Netbeans
),但当我通过链接将jar发送到Windows控制台(运行jframe
应用程序)时,它不会在字符串"Bohinjska Češnjica"
中显示字符'Č'
和'š'
的正确字符。应用程序中的Unicode字符无法正确显示
String example="Bohinjska Češnjica";
我从网站该字符串。 如何在Swing应用程序中编码或显示为("Bohinjska Češnjica")
,所以当我运行jframe
应用程序时,它会向我显示这些字符(以及其他Unicode字符ofcourse('Ž','ž','č'和' S'))?
链接1:jar file of my program runned from console 链路2:when i run program from netbeans
READING含量网站:
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...
}
您是否检查过从网站收到的字符串的编码? – pintxo 2015-03-13 08:52:54
这是一个纯文本。我会很快发布链接到一个图像,所以你会看到我的意思。 – slodeveloper 2015-03-13 13:42:09
为了尽快提供更好的帮助,请发布[MCVE](http://stackoverflow.com/help/mcve)(最小完整可验证示例)或[SSCCE](http://www.sscce.org/)(Short,Self包含,正确示例)。 – 2015-03-14 06:03:05