title: C#: bytes to UTF-8 string conversion. Why doesn't it work?
body: <p>There is a Chinese character  which is presented in UTF-8 as F0 A4 AD A2. This character is described here: <a href="http://en.wikipedia.org/wiki/UTF-8" rel="nofollow">http://en.wikipedia.org/wiki/UTF-8</a></p>
  
  <p>  U+24B62    F0 A4 AD A2</p>
  
  <p>When I run this code in <strong>C#</strong> ...</p>
  
  <pre><code>byte[] data = { 0xF0, 0xA4, 0xAD, 0xA2 };
  string abc = Encoding.UTF8.GetString(data);
  Console.WriteLine("Test: description = {0}", abc);
  </code></pre>
  
  <p>... I redirect the output to the text file and then open it with notepad.exe choosing UTF-8 encoding. I expect to get  in the output, but do get two question marks (??). </p>
  
  <p>The byte sequence is right. It works <strong>in Perl</strong>: </p>
  
  <pre><code>print "\xF0\xA4\xAD\xA2";
  </code></pre>
  
  <p>In the output, I get </p>
  
  <p><strong>So my question is:</strong> why do I get "??" instead of "" in <strong>C#</strong>?</p>
  
  <p>P.S. Nothing special with this character: I got the same thing for any character (2, 3 or 4 byte long).</p>