您好,欢迎访问一九零五行业门户网

php中utf-8转unicode,phputf-8转unicode_PHP教程

php中utf-8转unicode,phputf-8转unicodepublic function utf8_unicode($str) { $unicode = array(); $values = array(); $lookingfor = 1; for ($i = 0; $i < strlen( $str ); $i++ ) { $thisvalue = ord( $str[ $i ] ); if ( $thisvalue = ord('0') && $thisvalue <= ord('9')) { // number $unicode[] = chr($thisvalue); } else { $unicode[] = '%'.dechex($thisvalue); } } else { if ( $thisvalue < 128) { $unicode[] = $str[ $i ]; } else { if ( count( $values ) == 0 ) { $lookingfor = ( $thisvalue < 224 ) ? 2 : 3; } $values[] = $thisvalue; if ( count( $values ) == $lookingfor ) { $number = ( $lookingfor == 3 ) ? ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ): ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 ); $number = dechex($number); $unicode[] = (strlen($number)==3)?\u0.$number:\u.$number; $values = array(); $lookingfor = 1; } // if } // if } } // for return implode(,$unicode);}
参考文章:http://randomchaos.com/documents/?source=php_and_unicode
http://www.bkjia.com/phpjc/924849.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/924849.htmltecharticlephp中utf-8转unicode,phputf-8转unicode public function utf8_unicode( $str ) { $unicode = array (); $values = array (); $lookingfor = 1 ; for ( $i = 0; $i strlen ( $str ); $i ++...
其它类似信息

推荐信息