日期:2013-04-23  浏览次数:20438 次

//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;
}