0

テキストフィールドで使用するスカンジナビア文字を正しくエンコードする方法を見つけようとして、数日間頭を悩ませてきました

これらの 3 文字: Æ Ø Å ( æ ø å) は ��� として表示されます。つまり、このコードを実行すると

System.out.println("øst");

「�st」を印刷します。理由がわかりません。

System.out を printstream にリダイレクトするコードを次に示します。

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);
    }

誰かがこの問題の解決策を持っているなら、それは大歓迎です!

4

2 に答える 2