码迷,mamicode.com
首页 > Web开发 > 详细

PHP 转换接口编码

时间:2014-10-20 11:28:17      阅读:419      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   for   sp   数据   div   2014   

2014年10月20日 10:45:19

有些时候调用接口的时候返回数据的编码不是utf-8的,需要转码

1 foreach ($arrInfo as $k => $v) {
2     $encodeing = mb_detect_encoding($v, array(‘ASCII‘,‘GB2312‘,‘GBK‘,‘UTF-8‘));
3     if ($encodeing != ‘UTF-8‘) {
4         $arrUserInfo[$k] = iconv($encodeing, ‘UTF-8‘, $v);
5     }
6 }

注意: 编码是gb2312格式的话返回的编码格式是euc-cn (entended unix code)

PHP 转换接口编码

标签:style   blog   color   ar   for   sp   数据   div   2014   

原文地址:http://www.cnblogs.com/iLoveMyD/p/4036678.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!