title: Convert String Encoding in C Language
body: <p>Basically I need to convert UTF-8 string to windows-1256 and I do it using following code:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  
  char* convert(char* pszStringToConvert)
  {
        int len = strlen(pszStringToConvert);  // get string length
        wchar_t* pwsz = new wchar_t[len+1];       // allocate storage for temporary UNICODE string
        MultiByteToWideChar(65001,0, pszStringToConvert, len, pwsz, len);
        WideCharToMultiByte(1256,0, pwsz, len, pszStringToConvert, len, NULL, FALSE);
        return pszStringToConvert;
  }
  
  
  int main()
  {
       char* arabic ="السلام";
      char* win = convert(arabic);
  
  
      printf("%s\n%",win);
  
      return 0;
  }
  </code></pre>
  
  <p>My source string is</p>
  
  <p>arabic ="السلام"</p>
  
  <p>But unfortunately my result string becomes</p>
  
  <p>win = Ø§Ù„Ø³Ù„Ø§Ù…</p>
  
  <p>What I'm doing wrong here?</p>