里面有各种大家开发中常用到的种编码如uft8->gbk gbk转utf8 繁体转简体 简体转繁体 utf8转unicode gbk转拼音 ascii转拼音 等
里面有各种大家开发中常用到的种编码如uft8->gbk gbk转utf8 繁体转简体 简体转繁体 utf8转unicode gbk转拼音 ascii转拼音 等
> 6 & 0x3f); $str .= (0x80 | $c & 0x3f); } elseif($c > 18); $str .= (0x80 | $c >> 12 & 0x3f); $str .= (0x80 | $c >> 6 & 0x3f); $str .= (0x80 | $c & 0x3f); } return $str;}/** * utf8转unicode * @param $c */function utf8_to_unicode($c) { switch(strlen($c)) { case 1: return ord($c); case 2: $n = (ord($c[0]) & 0x3f) << 6; $n += ord($c[1]) & 0x3f; return $n; case 3: $n = (ord($c[0]) & 0x1f) << 12; $n += (ord($c[1]) & 0x3f) << 6; $n += ord($c[2]) & 0x3f; return $n; case 4: $n = (ord($c[0]) & 0x0f) << 18; $n += (ord($c[1]) & 0x3f) << 12; $n += (ord($c[2]) & 0x3f) <= $asc)return $p; } }}/** * gbk转拼音 * @param $txt */function gbk_to_pinyin($txt) { if(charset != 'gbk') { $txt = iconv(charset,'gbk',$txt); } $l = strlen($txt); $i = 0; $pyarr = array(); $py = array(); $filename = codetabledir.'gb-pinyin.table'; $fp = fopen($filename,'r'); while(!feof($fp)) { $p = explode(-,fgets($fp,32)); $pyarr[intval($p[1])] = trim($p[0]); } fclose($fp); ksort($pyarr); while($i=128) { $asc = abs($tmp*256+ord($txt[$i+1])-65536); $i = $i+1; } else $asc = $tmp; $py[] = asc_to_pinyin($asc,$pyarr); $i++; } return $py;}
永久链接:
转载随意!带上文章地址吧。