P> no hate GBK Unicode UTF8 Kanji Conversion
PHP's conversion of Chinese characters has always been a rather troublesome thing.
The class contains four filters "&#[dec];", "& #x [hex];", "%u[hex]", "UTF8 conversion"
User-friendly and customizable filtering for your favorite operations
qswhu.php Download from here
Http://www.blueidea.com/user/qswh/qswhU.zip
Class qswhu{
var $qswhData;
function Qswhu ($filename = "qswhu.php") {
$this->qswhdata=file ($filename);
}
function decode ($STR, $pattern =0) {
$arr =array ("/&# (w+);/iu", "/((%WW) +)/I", "/%u (w{4,5})/iu");
if (Is_integer ($pattern)) {
if ($pattern >=count ($arr)) Die ("Invalid Function");
$pattern = $arr [$pattern];
}
Return Preg_replace_callback ($pattern, Array ($this, "U2GB"), $STR);
}
function U2GB ($arr) {
/****** (Qiushuiwuhen 2002-8-15) ******/
$ret = ""; $str = $arr [1];
if (Preg_match_all ("/%w{2}/", $str, $matches)) {
for ($i =0; $i <>
$CHR 1=hexdec (substr ($matches [0][$i],1);
$arr =array ("F0", "E0", "C0", "0");
for ($j =0; $j hexdec ($arr [$j])) break;
$CHR =hexdec (substr ($matches [0][$i],1)-hexdec ($arr [$j]);
while (+ + $j $str =dechex ($CHR);
if (strlen ($STR) ==4) {
$p =hexdec (substr ($str, 0,2)) -0x4d;
$q =hexdec (substr ($STR, 2));
http://www.bkjia.com/phpjc/445172.html Span id= "Indexurl" itemprop= "Indexurl" >www.bkjia.com true http://www.bkjia.com/phpjc/445172.html techarticle p Love no Hate GBK Unicode UTF8 Kanji Conversion PHP's Chinese character conversion has been a more troublesome thing this class built-in four filter #[dec];, #x [Hex];,%u[hex],utf8 conversion for user-friendly use, while ...