title: WinHttpRequest POST
body: <p>I'm trying to read data from my online mySQL server using WinHttpRequest in VBA. </p>
  
  <pre class="lang-vb prettyprint-override"><code>Dim objHTTP As New WinHttp.WinHttpRequest
  With objHTTP
      .Open "POST", "http://www.dname.com/ruski/php/getNewestPID.php", True
      .SetRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=""UTF-8"""
      .Send "PID=" &amp; lngPID
      .WaitForResponse
      Debug.Print .ResponseText
  End With
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  $PID = $_POST['PID'];
  
  require_once ('config.php'); 
  
  if(!$PID&gt;0){
      die("##### Error: getNewestPID failed - PID='" . $PID . "'  #####");
  }
  
  $phrases = mysql_query("SELECT * FROM phrases WHERE (PID &gt; '$PID')");
  
  if(!$phrases){
      die("##### Error: getNewestPID SELECT failed - PID=" . $PID . " - " . mysql_error() . "  #####");
  }
  
  mysql_close($db);
  
  echo "data=";
  while($row = mysql_fetch_array($phrases)) {
      echo $row[0] . "|" . $row[1] . "|" . $row[2] . "|" . $row[3];
  }
  ?&gt;
  </code></pre>
  
  <p>All works well, but cyrillic text is returned like: </p>
  
  <p>data=21361|105||Ð?Ð°Ð»Ñ?Ñ?Ð¸Ðº Ð¸Ð³Ñ?Ð°ÐµÑ? Ð½Ð° ÑÐºÑ?Ð¸Ð¿ÐºÐµ Ð² ÑÐ²Ð¾ÐµÐ¹ ÐºÐ¾Ð¼Ð½Ð°Ñ?Ð</p>
  
  <p>My db uses UTF-8 Unicode. I know cyrillic works in tables and forms, but views junk in the VB editor.</p>
  
  <p>I tried this:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Set FileStream = CreateObject("ADODB.Stream")
  FileStream.Open
  FileStream.Type = 1 'Binary
  FileStream.Write objHTTP.ResponseBody
  FileStream.Position = 0
  FileStream.Type = 2 'adTypeText
  FileStream.Charset = "Windows-1251"  ' https://msdn.microsoft.com/en-us/library/ms526296(v=exchg.10).aspx
  strText = FileStream.ReadText
  FileStream.Close
  </code></pre>
  
  <p>ending up with junk in the record:</p>
  
  <p>РњР°Р»СЊС‡РёРє РёРіСЂР°РµС‚ РЅР° СЃРєСЂРёРїРєРµ РІ СЃРІРѕРµР№ РєРѕРјРЅР°С‚Рµ.</p>
  
  <p>The best result is with:</p>
  
  <p>mb_convert_encoding($row[3], "Windows-1251", "UTF-8")</p>
  
  <p>Ìàëü÷èê èãðàåò íà ñêðèïêå â ñâîåé êîìíàòå.</p>