if ($c < 0x80) {
  $str .= $c;
 } else ">

织梦之Unicode转utf8

80酷酷网    80kuku.com

  //Unicode转utf8
function u2utf8($c) {
 for ($i = 0;$i < count($c);$i++)
  $str = "";
 if ($c < 0x80) {
  $str .= $c;
 } else if ($c < 0x800) {
  $str .= (0xC0 | $c >> 6);
  $str .= (0x80 | $c & 0x3F);
 } else if ($c < 0x10000) {
  $str .= (0xE0 | $c >> 12);
  $str .= (0x80 | $c >> 6 & 0x3F);
  $str .= (0x80 | $c & 0x3F);
 } else if ($c < 0x200000) {
  $str .= (0xF0 | $c >> 18);
  $str .= (0x80 | $c >> 12 & 0x3F);
  $str .= (0x80 | $c >> 6 & 0x3F);
  $str .= (0x80 | $c & 0x3F);
 }
 return $str;
}


分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: