title: Chinese character in source code when UTF-8 settings can't be used
body: <p>This is the scenario:</p>
  
  <ul>
  <li>I can only use the <code>char*</code> data type for the string, not <code>wchar_t *</code></li>
  <li>My MS Visual C++ compiler has to be set to MBCS, not UNICODE because the third party source code that I have is using MBCS; Setting it to UNICODE will cause data type issues.</li>
  <li>I am trying to print chinese characters on a printer which needs to get a character string so it can print correctly</li>
  </ul>
  
  <p>What should I do with this line to make the code correct: <code>char * str = "你好";</code></p>
  
  <p>Convert it to hex sequence perhaps? If yes, how? Thanks a lot.</p>
  
  <pre><code>char * str = "你好";
  size_t len = strlen(str) + 1;
  
  
  wchar_t * wstr = new wchar_t[len];
  size_t convertedSize  = 0;
  mbstowcs_s(&amp;convertedSize, wstr, len, str, _TRUNCATE);
  cout &lt;&lt; convertedSize;
  
  if(! ExtTextOutW(resource-&gt;dc, 1,1 , ETO_OPAQUE, NULL, wstr ,  convertedSize, NULL))
  {
    return 0;
  }
  </code></pre>
  
  <p><strong>UPDATE</strong> : Let's put the question in another way</p>
  
  <p>I have this, the char * str contain sequence of UTF-8 code units, for the 2 chinese character 你好 ， the ExtTextOutW still cannot execute the wstr correctly, because I think the my code for mbstowcs_s could still not working correctly. Any idea why ?</p>
  
  <pre><code>char * str = "\xE4\xBD\xA0\xE5\xA5\xBD";    
      size_t len = strlen(str) + 1;
      wchar_t * wstr = new wchar_t[len];
      size_t convertedSize  = 0;
      mbstowcs_s(&amp;convertedSize, wstr, len, str, _TRUNCATE);
      if(! ExtTextOutW(resource-&gt;dc, 1,1 , ETO_OPAQUE, NULL,  wstr ,  len, NULL))
      {
          return 0;
      }
  </code></pre>