function ecstart_gbk_convert($buffer){
$slen=strlen($buffer);
$buffero=$buffer;
$buffer=iconv("gbk","big5",$buffer);
$olen=strlen($buffer);
if($slen != $olen)
{
$buffer=$buffer.ecstart_gbk2htmlunicode(substr($buffero,$olen,2)).ecstart_gbk_convert(substr($buffero,$olen+2));
}
return $buffer;
}
function ecstart_gbk2htmlunicode($buffer){
$len=strlen($buffer);
for($i=0;$i {
$h=ord($buffer[$i]);
if($h >= 0x81){
$tmpstr=iconv("gbk","utf16",$buffer[$i].$buffer[$i+1]);
$uni=hexdec(bin2hex($tmpstr[3].$tmpstr[2]));
$unicode .= "".$uni.";";
$i++;
}else{
$unicode .= $string[$i];
}
}
return $unicode;
}
function ecstart_utf8_convert($buffer){
$buffer=iconv("utf8","gbk",$buffer);
$buffer=ecstart_gbk_convert($buffer);
return $buffer;
}[@more@]
$slen=strlen($buffer);
$buffero=$buffer;
$buffer=iconv("gbk","big5",$buffer);
$olen=strlen($buffer);
if($slen != $olen)
{
$buffer=$buffer.ecstart_gbk2htmlunicode(substr($buffero,$olen,2)).ecstart_gbk_convert(substr($buffero,$olen+2));
}
return $buffer;
}
function ecstart_gbk2htmlunicode($buffer){
$len=strlen($buffer);
for($i=0;$i {
$h=ord($buffer[$i]);
if($h >= 0x81){
$tmpstr=iconv("gbk","utf16",$buffer[$i].$buffer[$i+1]);
$uni=hexdec(bin2hex($tmpstr[3].$tmpstr[2]));
$unicode .= "".$uni.";";
$i++;
}else{
$unicode .= $string[$i];
}
}
return $unicode;
}
function ecstart_utf8_convert($buffer){
$buffer=iconv("utf8","gbk",$buffer);
$buffer=ecstart_gbk_convert($buffer);
return $buffer;
}[@more@]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/786540/viewspace-968892/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/786540/viewspace-968892/