C#: How to print a unicode string to console?

Posted by Lopper on Stack Overflow See other posts from Stack Overflow or by Lopper
Published on 2010-04-14T15:54:58Z Indexed on 2010/04/14 16:03 UTC
Read the original article Hit count: 413

Filed under:
|
|
|

How do I print out the value of a unicode String in C# to the console?

byte[] unicodeBytes = new byte[] 
    {0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 
     0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x70, 0x63, 
     0x61, 0x70};

string unicodeString = Encoding.Unicode.GetString(unicodeBytes);

Console.WriteLine(unicodeString);

What I get for the above is "?????????"

However, I see the following in the autos and local window when in debug mode for the value of unicodeString which is what I wanted to display.

"??????????"

How do I print out the correct result to the console as what the autos and local window for debugging demonstrated?

© Stack Overflow or respective owner

Related posts about c#

Related posts about unicode