【发布时间】:2015-12-08 11:18:40
【问题描述】:
这几天我一直在摸不着头脑,试图弄清楚如何正确编码斯堪的纳维亚字符以在文本字段中使用
这三个字符:Æ Ø Å ( æ ø å) 显示为 ���。 意思是运行这段代码
System.out.println("øst");
打印"�st" .我不知道为什么。
这是我将 System.out 重定向到打印流的代码。
System.setProperty("user.language", "da");
OutputStream out = new OutputStream() {
@Override
public void write(int b) throws IOException {
appendConsole(new String(new byte[]{(byte)b}, "UTF-8"));
}
};
PrintStream ps;
try {
ps = new PrintStream(out, true, "UTF-8");
System.setOut(ps);
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(GameController.class.getName()).log(Level.SEVERE, null, ex);
}
如果有人能解决这个问题,不胜感激!
【问题讨论】:
标签: java encoding byte outputstream printstream