PHP Kanji Conversion: Unicode (UTF8) to gbk_php tutorial

Source: Internet
Author: User
Tags php download
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.