title: C# Encoding.Convert Vs C++ MultiByteToWideChar
body: <p>I have a C++ code snippet that uses MultiByteToWideChar to convert UTF-8 string to UTF-16</p>
  
  <p>For C++, if input is "HÃ´tel", the output is "Hôtel" which is correct</p>
  
  <p>For C#, if input is "HÃ´tel", the output is "HÃ´tel" which is not correct.</p>
  
  <p>The C# code to convert from UTF8 to UTF16 looks like</p>
  
  <pre><code>Encoding.Unicode.GetString(
              Encoding.Convert(
                  Encoding.UTF8,
                  Encoding.Unicode,
                  Encoding.UTF8.GetBytes(utf8)));
  </code></pre>
  
  <p>In C++ the conversion code looks like</p>
  
  <pre><code>MultiByteToWideChar(
      CP_UTF8,            // convert from UTF-8
      0,                  // default flags
      utf8.data(),        // source UTF-8 string
      utf8.length(),      // length (in chars) of source UTF-8 string
      &amp;utf16[0],          // destination buffer
      utf16.length()      // size of destination buffer, in wchar_t's
      )
  </code></pre>
  
  <p>I want to have the same results in C# that I am getting in C++. Is there anything wrong with the C# code ?</p>