【问题标题】:Issue with printing a degree symbol (°) in Swing在 Swing 中打印度数符号 (°) 的问题
【发布时间】:2018-04-17 18:45:24
【问题描述】:

我有一个简单的程序,可以在 Swing 中显示来自气象站的数据。我正在使用System.out.print(temp + "\u00B0" + "F"); 来显示温度。在 Windows 上显示为“70°F”,但在 MacOS 上显示为“70°F”。有没有办法在所有平台上可靠地显示度数符号?

【问题讨论】:

    标签: java macos swing unicode


    【解决方案1】:

    试试这个:

    PrintStream out = new PrintStream( System.out, true, StandardCharsets.UTF_8 );
    out.println( temp + "\u00B0" + "C" );
    

    (顺便说一句,我也冒昧地修复了你的温度测量系统。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-25
      • 2019-12-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多