locked
Console.writeline doesnt display chinese character in english os,help RRS feed

  • Question

  • my code is really simple, just one line: Console.WriteLine("中文");
    and in my computer(chinese os) is ok. but in english version os, it display "??"
    i try to set the Console.OutputEncoding= Encoding.UTF8,and it displays irrecognizable characters.
    i check the control panel of the english os, and the language for non-unicode program is english(united states), and the system default encoding is 1252 western european<windows>.
    and i can type chinese character in my explorer search bar. file name can be chinese, even my another program which will write some chinese characters to some file is ok as well.
    so i really confuse, why is console not displaying my string correctly.
    Thursday, September 24, 2009 6:21 PM

Answers

  • Console mode programs are stuck with non-Unicode support.  Necessarily so because their output can be redirected.  They're not going to display Chinese characters properly unless the system code page is Chinese.

    The other programs you used that properly supported your Chinese input are Unicode enabled.  Which is the way to get ahead, write a real Windows program instead of console mode apps.  It isn't hard with Windows Forms.

    Hans Passant.
    • Proposed as answer by JohnGrove Thursday, September 24, 2009 8:58 PM
    • Marked as answer by Ji.Zhou Thursday, October 1, 2009 3:53 AM
    Thursday, September 24, 2009 8:13 PM

All replies