php教程|php手册
word,function,return,uncode,decode
php教程-php手册
这是一个将汉字转换成Unicode编码的PHP函数,支持GBK和UTF8编码。
function uni_decode ($uncode)
{
$word = json_decode(preg_replace_callback(‘/&#(\d{5});/’, create_function(‘$dec’, ‘return \’\\u\’.dechex($dec[1]);’), ‘”‘.$uncode.”‘));
return $word;
}
对 Unicode 转换为汉字
function uni_decode ($uncode)
{
$word = json_decode(preg_replace_callback(‘/&#(\d{5});/’, create_function(‘$dec’, ‘return \’\\u\’.dechex($dec[1]);’), ‘”‘.$uncode.”‘));
return $word;
}
以下示例演示:
function uni_encode ($word)
{
$word0 = iconv(‘gbk’, ‘utf-8’, $word);
$word1 = iconv(‘utf-8’, ‘gbk’, $word0);
$word = ($word1 == $word) ? $word0 : $word;
$word = json_encode($word);
$word = preg_replace_callback(‘/\\\\u(\w{4})/’, create_function(‘$hex’, ‘return \’&#\’.hexdec($hex[1]).\’;\’;’), substr($word, 1, strlen($word)-2));
return $word;
}
$word = ‘将朱祖松和霍涛转为 Unicode 四字节编码! ‘;
echo uni_encode($word);
上述将输出如下结果:
android管理系统源码下载,Ubuntu查存储,tomcat错误怎么办,爬虫 风控,php网站开发需求文档,seo技术整站快速排名推广平台lzw
本文链接/html/wlbc/Php/0326/37396.html
网站源码教程,关闭试用ubuntu太慢,tomcat最先加载哪个类,调查爬虫宠物,php 宠物管理系统,我经历过最牛的seo公司lzw
园林绿化公司 源码,gpart给ubuntu扩容,tomcat免安装下哪个,爬虫软件特点,net调用php,随州什么是seo关键词优化lzw