Convert UTF-8 to Window 874 using PHP
<p>I have encoded string like <code>ªÙªÑÂ  à¾ç§Íé¹</code></p>

<p>Please check below function that i have used for decode(utf-8 to tis620) it.</p>

<pre><code>function utf8_to_tis620($string) {
   $str = $string;
   $res = "";
   for ($i = 0; $i &lt; strlen($str); $i++) {
      if (ord($str[$i]) == 224) {
        $unicode = ord($str[$i+2]) &amp; 0x3F;
        $unicode |= (ord($str[$i+1]) &amp; 0x3F) &lt;&lt; 6;
        $unicode |= (ord($str[$i]) &amp; 0x0F) &lt;&lt; 12;
        $res .= chr($unicode-0x0E00+0xA0);
        $i += 2;
      } else {
        $res .= $str[$i];
      }
   }
   return $res;
}
</code></pre>

<p>So it will return string like <code>ชูชัย  Gงอ้น</code> but it isn't correct in THAI language.</p>

<p>Actually it should return <code>ชูชัย เพ็งอ้น</code> that is returned from <a href="http://string-functions.com/encodedecode.aspx" rel="nofollow">http://string-functions.com/encodedecode.aspx</a>.</p>

<p>But there is used windows 874 decoding.</p>

<p>Please let me know how can i decode utf-8 to windows 874 in php?</p>