• 技术文章 >后端开发 >php教程

    php的汉字转换GBK-UnicodeUTF8_PHP教程

    2016-07-13 17:25:36原创399
    php的汉字转换一直是比较麻烦的事
    该类内置了四个函数"htmlHex","htmlDec","escape","u2utf8"
    方便用户的使用,同时也可自定义函数进行自己喜欢的操作
    qswhGBK.php 从这里下载
    http://www.blueidea.com/user/qswh/qswhGBK.zip
    class qswhGBK{
    var $qswhData;
    function qswhGBK($filename="qswhGBK.php"){
    $this->qswhData=file($filename);
    }
    function gb2u($gb,$callback=""){
    /******(qiushuiwuhen 2002-8-15)******/
    $ret="";
    for($i=0;$i if(($p=ord(substr($gb,$i,1)))>127){
    $q=ord(substr($gb,++$i,1));
    $q=($q-($q>128?65:64))*4;
    $q=substr($this->qswhData[$p-128],$q,4);
    }
    else
    $q=dechex($p);
    if(empty($callback))
    $ret.=$q;
    else {
    $arr=array("htmlHex","htmlDec","escape","u2utf8");
    if(is_integer($callback)){
    if($callback>count($arr))die("Invalid Function");
    $ret.=$this->$arr[$callback-1]($q);
    }else
    $ret.=$callback($q);
    }
    }
    return $ret;

    }
    function htmlHex($str){
    return "&#x".$str.";";
    }
    function htmlDec($str){
    return "&#".hexdec($str).";";
    }
    function escape($str){
    return hexdec($str)<256?chr(hexdec($str)):"%u".$str;
    }
    function u2utf8($str){
    /******(qiushuiwuhen 2002-8-15)******/
    $sp="!()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~";
    $dec=hexdec($str);
    $bin=decbin($dec);
    $len=strlen($bin);
    $arr=array("c0","e0","f0");
    if($dec>0x7f){
    $ret="";
    for($i=$len,$j=-1;$i>=0;$i-=6,$j++){
    if($i>6)
    $ret="%".dechex(0x80+bindec(substr($bin,$i-6,6))).$ret;
    else
    $ret="%".dechex(hexdec($arr[$j])+bindec(substr($bin,0,6-$i))).$ret;
    }
    }else{
    if(strpos($sp,chr($dec)))
    $ret=chr($dec);
    else
    $ret="%".strtolower($str);
    }
    return $ret;
    }
    }
    使用范例
    $words="中文Abc";
    function ex($str){return "[".$str."]";}
    $qswh=new qswhGBK("qswhGBK.php");//如果文件名是qswhGBK.php,可省参数echo("不带参数:".$qswh->gb2u($words));echo(" 调用内置函数htmlHex:".$qswh->gb2u($words,1));echo(" 调用内置函数htmlDec:".$qswh->gb2u($words,2));echo(" 调用内置函数escape:".$qswh->gb2u($words,3));echo(" 调用内置函数u2utf8:".$qswh->gb2u($words,4));echo(" 调用自定义函数:".$qswh->gb2u($words,ex));效果如下:不带参数:4E2D6587416263调用内置函数htmlHex:&#x4E2D;&#x6587;&#x41;&#x62;&#x63;调用内置函数htmlDec:&#20013;&#25991;&#65;&#98;&#99;调用内置函数escape:%u4E2D%u6587Abc调用内置函数u2utf8:%e4%b8%ad%e6%96%87Abc调用自定义函数:[4E2D][6587][41][62][63]ps.该文章现仅限在csdn文档中心,如要转载,请和作者联系,否则后果自负。 </p> <p align="left"><div style="display:none;"><span id="url" itemprop="url">http://www.bkjia.com/PHPjc/532056.html</span><span id="indexUrl" itemprop="indexUrl">www.bkjia.com</span><span id="isOriginal" itemprop="isOriginal">true</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http://www.bkjia.com/PHPjc/532056.html</span><span id="genre" itemprop="genre">TechArticle</span><span id="description" itemprop="description">php的汉字转换一直是比较麻烦的事 该类内置了四个函数"htmlHex","htmlDec","escape","u2utf8" 方便用户的使用,同时也可自定义函数进行自己喜欢的...</span></div></p></div> <div class="art_confoot"></div><div class='bg-white layui-clear' style="margin:15px 0;"><span style="color:red;">声明:</span>本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。</div><div class='tags bg-white layui-clear pt-5'><span>专题推荐:</span><a href="//m.sbmmt.com/m/search?word=php" target="_blank">php</a> <a href="//m.sbmmt.com/m/search?word=的" target="_blank">的</a> <a href="//m.sbmmt.com/m/search?word=汉字" target="_blank">汉字</a> <a href="//m.sbmmt.com/m/search?word=转换" target="_blank">转换</a> <a href="//m.sbmmt.com/m/search?word=gbk-unicodeutf8" target="_blank">GBK-UnicodeUTF8</a> <a href="//m.sbmmt.com/m/search?word=php" target="_blank">php</a> <a href="//m.sbmmt.com/m/search?word=的" target="_blank">的</a> <a href="//m.sbmmt.com/m/search?word=汉字" target="_blank">汉字</a> <a href="//m.sbmmt.com/m/search?word=转换" target="_blank">转换</a> <a href="//m.sbmmt.com/m/search?word=一直是" target="_blank">一直是</a> <a href="//m.sbmmt.com/m/search?word=比较" target="_blank">比较</a> <a href="//m.sbmmt.com/m/search?word=麻烦" target="_blank">麻烦</a> <a href="//m.sbmmt.com/m/search?word=事" target="_blank">事</a> <a href="//m.sbmmt.com/m/search?word=该类" target="_blank">该类</a> <a href="//m.sbmmt.com/m/search?word=内置" target="_blank">内置</a> <a href="//m.sbmmt.com/m/search?word=了" target="_blank">了</a> <a href="//m.sbmmt.com/m/search?word=" target="_blank"></a></div><div><span style="display:inline-block; width: 100%; margin-top: 10px;"> 上一篇:<a style="color: #00AEEF;" href="//m.sbmmt.com/m/article/301017.html">php中两个网页之间的变量传送_PHP教程</a></span><span style="display:inline-block; width: 100%"> 下一篇:<a style="color: #00AEEF;" href="//m.sbmmt.com/m/course/1467.html">自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)</a></span></div></article><!--<div class="selectButton"><button type="button">点击阅读全文</button></div>--><!--<a href="javascript:;" onclick="location.href='https://m.xp.cn/'" rel="nofollow"><img src="//m.sbmmt.com/m/static/images/articlead.jpg" width="100%" alt="phpstudy集成环境下载"></a>--><!--<a href="//m.sbmmt.com/m/vip_mobile.html" rel="nofollow"><img src="//m.sbmmt.com/m/static/images/articlead1.gif" width="100%" alt="会员特权"></a>--></div><div class='course-list bg-white layui-clear'><h4>相关文章推荐</h4><a href='//m.sbmmt.com/m/article/499603.html' title="浅析PHP中的类自动加载相关文件" class='alist'>• 浅析PHP中的类自动加载相关文件</a><a href='//m.sbmmt.com/m/article/499593.html' title="系统讲解PHP缓存技术" class='alist'>• 系统讲解PHP缓存技术</a><a href='//m.sbmmt.com/m/article/499577.html' title="一文理解和实现现代PHP框架里的IOC容器" class='alist'>• 一文理解和实现现代PHP框架里的IOC容器</a><a href='//m.sbmmt.com/m/article/499558.html' title="深入了解PHP:用gdb调试源码" class='alist'>• 深入了解PHP:用gdb调试源码</a><a href='//m.sbmmt.com/m/article/499556.html' title="实例介绍:使用Docker快速搭建多版本PHP开发环境" class='alist'>• 实例介绍:使用Docker快速搭建多版本PHP开发环境</a></div><div id="phpad" style="max-width:640px; height:auto; min-height: 10px;"><a href="//m.sbmmt.com/jump/go.php?url=https%3A%2F%2Fm.sbmmt.com%2Fk.html&location=mob-banner-vue"><img src="//m.sbmmt.com/img/upload/aroundimg/000/000/001/63a01f357f088211.png" width="100%" /></a></div><div class='course-list bg-white layui-clear mt-10 mb-30'><ul ><h4>相关课程推荐</h4><li class='layui-clear' style="padding-left: 0px;"><a href="//m.sbmmt.com/m/course/386.html" class="course-arctic-img"><img src='//m.sbmmt.com/img/upload/course/000/000/001/5d1c6df423564706.jpg' height="100%"></a><div class='course-intro' style="margin-left: 0px;"><h2><a href="//m.sbmmt.com/m/course/386.html">独孤九贱(3)_JavaScript视频教程</a></h2><p class='course-intro-info'>javascript是运行在浏览器上的脚本语言,连续多年,被评为全球最受欢迎的编程语言。是前端开发必备三大法器中,最具杀伤力。如果前端开发是降龙十八掌,好么javascript就是第18掌:亢龙有悔。没有它,你的前端生涯是不完整的。《php.cn独孤九贱(3)-JavaScript视频教程》课程特色:php中文网原创幽默段子系列课程,以恶搞,段子为主题风格的php视频教程!轻松的教学风格,简短的教学模式,让同学们在不知不觉中,学会了javascript知识。</p><p><a href="//m.sbmmt.com/m/course/list/17.html"><span class='level'>JavaScript教程</span></a><span class='count'>140391次播放</span></p></div></li><hr><li class='layui-clear' style="padding-left: 0px;"><a href="//m.sbmmt.com/m/course/582.html" class="course-arctic-img"><img src='//m.sbmmt.com/img/upload/course/000/000/001/5d1c6e0d2b744633.jpg' height="100%"></a><div class='course-intro' style="margin-left: 0px;"><h2><a href="//m.sbmmt.com/m/course/582.html">独孤九贱(6)_jQuery视频教程</a></h2><p class='course-intro-info'>jQuery是一个快速、简洁的JavaScript框架。设计的宗旨是“write Less,Do More”,即倡导写更少的代码,做更多的事情。它封装JavaScript常用的功能代码,提供一种简便的JavaScript设计模式,优化HTML文档操作、事件处理、动画设计和Ajax交互。 核心特性可以总结为:具有独特的链式语法和短小清晰的多功能接口;具有高效灵活的css选择器,并且可对CSS选择器进行扩展;拥有便捷的插件扩展机制和丰富的插件。兼容各种主流浏览器,如IE 6.0+、FF 1.5+、Safari 2.0+、Opera 9.0+等,是全球最流行的前端开发框架之一。PHP中文网根据最新版本,独家录制jQuery最新视频教程,回馈PHP中文网的新老用户。</p><p><a href="//m.sbmmt.com/m/course/list/19.html"><span class='level'>jQuery教程</span></a><span class='count'>115335次播放</span></p></div></li><hr><li class='layui-clear' style="padding-left: 0px;"><a href="//m.sbmmt.com/m/course/1195.html" class="course-arctic-img"><img src='//m.sbmmt.com/img/upload/course/000/000/015/612f16c1e1c8e978.jpg' height="100%"></a><div class='course-intro' style="margin-left: 0px;"><h2><a href="//m.sbmmt.com/m/course/1195.html">jQuery与Ajax基础与实战</a></h2><p class='course-intro-info'>jQuery是最流行的JS函数库,封装了许多实用的功能,其中最引人入胜的就是Ajax。 jQuery中的Ajax操作,语法简单,操作方便,使Ajax从未如此轻松,前端人员从此不再为与服务器异步交互而发愁,本套课程,精选了最常用的几个方法,从基本的语法到每个参数,再到具体实例进行了全面的讲解。</p><p><a href="//m.sbmmt.com/m/course/list/25.html"><span class='level'>AJAX教程</span></a><span class='count'>14994次播放</span></p></div></li><hr><li class='layui-clear' style="padding-left: 0px;"><a href="//m.sbmmt.com/m/course/1313.html" class="course-arctic-img"><img src='//m.sbmmt.com/img/upload/course/000/000/015/617b8f8af2b97409.jpg' height="100%"></a><div class='course-intro' style="margin-left: 0px;"><h2><a href="//m.sbmmt.com/m/course/1313.html">Git教程(60分钟全程无废话版)</a></h2><p class='course-intro-info'>Git 是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。 Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。 Git 与常用的版本控制工具 CVS, Subversion 等不同,它采用了分布式版本库的方式,不必服务器端软件支持</p><p><a href="//m.sbmmt.com/m/course/list/17.html"><span class='level'>JavaScript教程</span></a><span class='count'>13133次播放</span></p></div></li><hr></ul></div><!-- <div class='discuss layui-clear bg-white'><h3>全部评论<span id='discuss-article'>我要评论</span></h3></div><div class='discuss-submit bg-white' url="//m.m.sbmmt.com/"><li class='info layui-clear'><span class='f-left' id='discuss-submit-close'>取消</span><span class='f-left'>发布评论</span><span class='f-right article-reply-publish' id="301018">发送</span></li><li class='layui-clear'><textarea type='text' rows="6" placeholder="请输入要评论的内容" class="article-reply-content-text"></textarea></li><li class='layui-clear'><button class="layui-btn layui-btn-danger f-right article-reply-publish-button">发布</button></li></div>--><div class='lock-screen' id='lock-screen'></div><div class='popimg-setting'><div>1/1</div><img src="" width='100%'></div><script src="//m.sbmmt.com/m/static/ueditor/third-party/SyntaxHighlighter/shCore.js"></script><script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script><footer><a href='//m.sbmmt.com/m/' ><i class='layui-icon layui-icon-home '></i>首页</a><a href='//m.sbmmt.com/m/course.html' ><i class='layui-icon layui-icon-play'></i>视频</a><a href='//m.sbmmt.com/m/mk.html?t=2'><img src="//m.sbmmt.com/img/upload/article/000/000/015/60ab3b6160ae1893.png" />直播</a><!-- <a href='//m.sbmmt.com/m/app/'><img src="//m.sbmmt.com/img/upload/article/000/000/003/6108e2ad07387877.png" style="width:20px;height:20px;" /><div style="margin-top:-5px;">下载</div></a>--><a href='//m.sbmmt.com/m/wenda.html' ><i class='layui-icon layui-icon-code-circle'></i>社区</a><a href='//m.sbmmt.com/m/login' ><i class='layui-icon layui-icon-username'></i>我的</a></footer><div class="headerMask"></div><div class="right_menu"><div class="right_menu_con" style="position:relative;"><h2 class="hjclass-txt"><i class="layui-icon layui-icon-shrink-right hjclass-txt-i"></i>PHP中文网</h2><div class="menu-list"><a href="//m.sbmmt.com/m/"><span class="item-icon item-1"><img src="//m.sbmmt.com/img/upload/article/000/000/003/5bffb65f99ae2304.png" alt="首页"></span> 首页</a><a href="//m.sbmmt.com/m/course.html"><span class="item-icon item-7"><img src="//m.sbmmt.com/img/upload/article/000/000/003/5bffb82bd09ad628.png" alt="课程"></span> 课程</a><a href="//m.sbmmt.com/m/article.html"><span class="item-icon item-4"><img src="//m.sbmmt.com/img/upload/article/000/000/003/5bffb7e111b3b425.png" alt="文章"></i></span>文章</a><a href="//m.sbmmt.com/m/wenda.html"><span class="item-icon item-2"><img src="//m.sbmmt.com/img/upload/article/000/000/003/5bffb83f04e24328.png" alt="问答"></span> 问答</a><a href="//m.sbmmt.com/m/blog.html"><span class="item-icon item-0"><img src="//m.sbmmt.com/m/static/images/ico/blog.png" alt="博客"></span>博客</a><a href="//m.sbmmt.com/m/dic.html"><span class="item-icon item-9"><img src="//m.sbmmt.com/img/upload/article/000/000/003/5bffb85047b25758.png" alt="词典"></span> 词典</a><a href="//m.sbmmt.com/m/course/type/99.html"><span class="item-icon item-3"><img src="//m.sbmmt.com/img/upload/article/000/000/003/5bffb8736ea90300.png" alt="手册"></span> 手册</a><a href="//m.sbmmt.com/m/xiazai/"><span class="item-icon item-5"><img src="//m.sbmmt.com/m/static/images/ico/resources.png" alt="资源"></span> 资源</a><a href="//m.sbmmt.com/m/search"><span class="item-icon item-6"><img src="//m.sbmmt.com/img/upload/article/000/000/003/5bffb880b460a204.png" alt="搜索"></span> 搜索</a><a href="//m.sbmmt.com/m/app/"><span class="item-icon item-6"><img src="//m.sbmmt.com/img/upload/article/000/000/003/608bbfa30d9cc398.png" style="width:35px;height:35px;" alt="APP下载"></span> APP下载</a></div><!-- <a href="//m.sbmmt.com/jump/go.php?url=https%3A%2F%2Fm.sbmmt.com%2Fmap%2F2.html&location=mob-mune-ad" style="display:block; position:absolute ; bottom:0px" target="_blank"><img src="//m.sbmmt.com/img/upload/aroundimg/000/000/001/62fdcfb67b3b8383.png" width="100%" /></a> --></div></div><script>isLogin = 0;</script><script type="text/javascript" src="//m.sbmmt.com/m/static/js/jquery.min.js"></script><script type="text/javascript" src="//m.sbmmt.com/m/static/layui/layui.js"></script><script type="text/javascript" src="//m.sbmmt.com/m/static/js/global.js?4.9.47"></script><script>(function () {var bp = document.createElement('script');var curProtocol = window.location.protocol.split(':')[0];if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';} else {bp.src = 'http://push.zhanzhang.baidu.com/push.js';}var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(bp, s);})();var _hmt = _hmt || [];(function() {var hm = document.createElement("script");hm.src = "https://m.sbmmt.com/hm.js?43f47cabf6856204df6d083dd89ae407";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(hm, s);})();</script><link rel='stylesheet' id='_main-css' href='//m.sbmmt.com/m/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='//m.sbmmt.com/m/static/js/viewer.min.js?1'></script><script type='text/javascript' src='//m.sbmmt.com/m/static/js/jquery-viewer.min.js'></script><script> // function called if wwads is blocked function ABDetected() { document.getElementsByClassName("wwads-cn")[0].insertAdjacentHTML("beforeend", "<style>.wwads-horizontal,.wwads-vertical{background-color:#f4f8fa;padding:5px;min-height:120px;margin-top:20px;box-sizing:border-box;border-radius:3px;font-family:sans-serif;display:flex;min-width:150px;position:relative;overflow:hidden;}.wwads-horizontal{flex-wrap:wrap;justify-content:center}.wwads-vertical{flex-direction:column;align-items:center;padding-bottom:32px}.wwads-horizontal a,.wwads-vertical a{text-decoration:none}.wwads-horizontal .wwads-img,.wwads-vertical .wwads-img{margin:5px}.wwads-horizontal .wwads-content,.wwads-vertical .wwads-content{margin:5px}.wwads-horizontal .wwads-content{flex:130px}.wwads-vertical .wwads-content{margin-top:10px}.wwads-horizontal .wwads-text,.wwads-content .wwads-text{font-size:14px;line-height:1.4;color:#0e1011;-webkit-font-smoothing:antialiased}.wwads-horizontal .wwads-poweredby,.wwads-vertical .wwads-poweredby{display:block;font-size:11px;color:#a6b7bf;margin-top:1em}.wwads-vertical .wwads-poweredby{position:absolute;left:10px;bottom:10px}.wwads-horizontal .wwads-poweredby span,.wwads-vertical .wwads-poweredby span{transition:all 0.2s ease-in-out;margin-left:-1em}.wwads-horizontal .wwads-poweredby span:first-child,.wwads-vertical .wwads-poweredby span:first-child{opacity:0}.wwads-horizontal:hover .wwads-poweredby span,.wwads-vertical:hover .wwads-poweredby span{opacity:1;margin-left:0}.wwads-horizontal .wwads-hide,.wwads-vertical .wwads-hide{position:absolute;right:-23px;bottom:-23px;width:46px;height:46px;border-radius:23px;transition:all 0.3s ease-in-out;cursor:pointer;}.wwads-horizontal .wwads-hide:hover,.wwads-vertical .wwads-hide:hover{background:rgb(0 0 0 /0.05)}.wwads-horizontal .wwads-hide svg,.wwads-vertical .wwads-hide svg{position:absolute;left:10px;top:10px;fill:#a6b7bf}.wwads-horizontal .wwads-hide:hover svg,.wwads-vertical .wwads-hide:hover svg{fill:#3E4546}</style><a href='https://wwads.cn/page/whitelist-wwads' class='wwads-img' target='_blank' rel='nofollow'><img src='https://creatives-1301677708.file.myqcloud.com/images/placeholder/wwads-friendly-ads.png' width='130'></a><div class='wwads-content'><a href='https://wwads.cn/page/whitelist-wwads' class='wwads-text' target='_blank' rel='nofollow'>为了本站的长期运营,请将我们的网站加入广告拦截器的白名单,感谢您的支持!</a><a href='https://wwads.cn/page/end-user-privacy' class='wwads-poweredby' title='万维广告 ~ 让广告更优雅,且有用' target='_blank'><span>万维</span><span>广告</span></a></div><a class='wwads-hide' onclick='parentNode.remove()' title='隐藏广告'><svg xmlns='http://www.w3.org/2000/svg' width='6' height='7'><path d='M.879.672L3 2.793 5.121.672a.5.5 0 11.707.707L3.708 3.5l2.12 2.121a.5.5 0 11-.707.707l-2.12-2.12-2.122 2.12a.5.5 0 11-.707-.707l2.121-2.12L.172 1.378A.5.5 0 01.879.672z'></path></svg></a>"); }; //check document ready function docReady(t) { "complete" === document.readyState || "interactive" === document.readyState ? setTimeout(t, 1) : document.addEventListener("DOMContentLoaded", t); } //check if wwads' fire function was blocked after document is ready with 3s timeout (waiting the ad loading) docReady(function () { setTimeout(function () { if( window._AdBlockInit === undefined ){ ABDetected(); } }, 3000); }); </script><script> var returnCitySN = ''; // document.getElementById("phpad").style.display="none"; // document.getElementById("phpcontent").style.display="none"; // document.getElementById("app_open").style.display="none"; </script><script type="text/javascript" charset="UTF-8" src="//m.sbmmt.com/ip/city.php?sign=fe05793809deeaaeeb53344d139a25e6"></script><script> function setCookie(name,value,iDay){ //name相当于键,value相当于值,iDay为要设置的过期时间(天) var oDate = new Date(); oDate.setDate(oDate.getDate() + iDay); document.cookie = name + '=' + value + ';path=/;domain=.php.cn;expires=' + oDate; } //读cookies function getCookiea(name) { var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); if(arr=document.cookie.match(reg)) return arr[2]; else return null; } // var ad = getCookiea('ad'); // if( returnCitySN == '' || encodeURIComponent(returnCitySN.cname).indexOf('%E6%96%B0%E7%96%86') != -1 || encodeURIComponent(returnCitySN.cname).indexOf('%E5%8C%97%E4%BA%AC') != -1) // { // $('#phpad').remove(); // $('#phpcontent').remove(); // $('#app_open').remove(); // } // else // { // setCookie('ad',1,1) // document.getElementById("phpad").style.display=""; // document.getElementById("phpcontent").style.display=""; // document.getElementById("app_open").style.display=""; // } </script><script>$('article').viewer({navbar:true,title:false,toolbar:false,movable:false,viewed:function(){$('img').click(function(){$('.viewer-close').trigger('click');});}});</script><script type="application/ld+json">{"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld","@id": "//m.m.sbmmt.com/article/301018.html","appid": "1549852514326010","title": "php的汉字转换GBK-UnicodeUTF8_PHP教程","images": [""],"description": "php的汉字转换GBK-UnicodeUTF8。php的汉字转换一直是比较麻烦的事 该类内置了四个函数"htmlHex","htmlDec","escape","u2utf8" 方便用户的使用,同时也可自定义函数进行自己喜欢的","pubDate": "2016-07-13T17:25:36","data": {"WebPage": {"headline": "php的汉字转换GBK-UnicodeUTF8_PHP教程","wapUrl": "//m.m.sbmmt.com/article/301018.html","pcUrl": "//m.sbmmt.com/m/php-weizijiaocheng-301018.html","fromSrc": "php中文网","domain": "电子科技","category": ["问答"],"isDeleted": 0},"Question": [{"acceptedAnswer":"php的汉字转换GBK-UnicodeUTF8。php的汉字转换一直是比较麻烦的事 该类内置了四个函数"htmlHex","htmlDec","escape","u2utf8" 方便用户的使用,同时也可自定义函数进行自己喜欢的"}],"ImageObject": [{"contentUrl": "","scale": "5:2"}],"Author": [{"name": "php中文网","jobTitle": ["php公益学习平台"],"headPortrait": "https://img.php.cn/upload/article/000/000/003/5d1b23156bf94358.png"}]}}</script><script>$('.selectButton').hide();</script><script> var href = window.location.href; var title = document.title; var num = Math.floor(Math.random() * 10000 + 1); var newscript = document.createElement('script'); newscript.setAttribute('type','text/javascript'); newscript.setAttribute('src',"https://analyze.xm6wpp.com/index.php/api/statistics/phpcn?url="+encodeURIComponent(href)+"&title="+encodeURIComponent(title)+"&"+num); var head = document.getElementsByTagName('head')[0]; head.appendChild(newscript); </script></body></html>