UTF-8 CJK characters not displaying in Java

后端 未结 4 554
天涯浪人
天涯浪人 2020-12-10 13:27

I\'ve been reading up on Unicode and UTF-8 encoding for a while and I think I understand it, so hopefully this won\'t be a stupid question:

I have a file which conta

4条回答
  •  醉梦人生
    2020-12-10 13:41

    The following program prints CJK characters to the console using TextPad. To see the Korean Hangul and Japanese Hiragana I had to tell Java to change the print stream's encoding to EUC_KR and set the properties of TextPad's tool output window:

    • font is Arial Unicode MS
    • script is Hangul

    import java.io.PrintStream;
    import java.io.UnsupportedEncodingException;
    
    class Hangul {
    
        public static void main(String[] args)  throws Exception {
    
            // Change console encoding to Korean
    
            PrintStream out = new PrintStream(System.out, true, "EUC_KR");
            System.setOut(out);
    
            // Print sample to console
    
            String go_hello  = "가다 こんにちは";
            System.out.println(go_hello);
        }
    }
    

    Tool Output is:

    가다 こんにちは

提交回复
热议问题