21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
function utf8_replaceEntity($result){
$value = (int)$result[1];
$string = '';
$len = round(pow($value,1/8));
for($i=$len;$i>0;$i--){
$part = ($value & (255>>2)) | pow(2,7);
if ( $i == 1 ) $part |= 255<<(8-$len);
$string = chr($part) . $string;
$value >>= 6;
}
return $string;
}
function utf8_html_entity_decode($string){
return preg_replace_callback(
'/&#([0-9]+);/u',
'utf8_replaceEntity',
$string
);
}
$string = '华南';
$string = utf8_html_entity_decode($string);
header('Content-Type: text/html; charset=UTF-8');
echo '<li>'.$string;
?>