一段把html编码的转换为正常utf8文字的php代码html2utf8
<?php
function html_to_utf8 ($data)
{
return preg_replace("/\&\#([0-9])\;/e", '_html_to_utf8("")', $data);
}
function _html_to_utf8 ($data)
{
if ($data > 127)
{
$i = 5;
while (($i--) > 0)
{
if ($data != ($a = $data % ($p = pow(64, $i))))
{
$ret = chr(base_convert(str_pad(str_repeat(1, $i + 1), 8, "0"), 2, 10) + (($data - $a) / $p));
for ($i; $i > 0; $i--)
$ret .= chr(128 + ((($data % pow(64, $i)) - ($data % ($p = pow(64, $i - 1)))) / $p));
break;
}
}
}
else
$ret = "&#$data;";
return $ret;
}
header("Content-Type: text/html; charset=UTF-8");
$string = '半自動波';
echo html_to_utf8($string);
?>
另外还有一段编码转换的代码在这里
收藏html2utf8到百度搜藏

(142)
(131)
(311)
(236)
(70)
(24)
(6)
(162)
(44)
(24)
(24)
(6)
(2)
(3)
(16)
(11)
(3)