【发布时间】:2018-04-17 18:45:24
【问题描述】:
我有一个简单的程序,可以在 Swing 中显示来自气象站的数据。我正在使用System.out.print(temp + "\u00B0" + "F"); 来显示温度。在 Windows 上显示为“70°F”,但在 MacOS 上显示为“70°F”。有没有办法在所有平台上可靠地显示度数符号?
【问题讨论】:
我有一个简单的程序,可以在 Swing 中显示来自气象站的数据。我正在使用System.out.print(temp + "\u00B0" + "F"); 来显示温度。在 Windows 上显示为“70°F”,但在 MacOS 上显示为“70°F”。有没有办法在所有平台上可靠地显示度数符号?
【问题讨论】:
试试这个:
PrintStream out = new PrintStream( System.out, true, StandardCharsets.UTF_8 );
out.println( temp + "\u00B0" + "C" );
(顺便说一句,我也冒昧地修复了你的温度测量系统。)
【讨论】: