最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php判断页面输入字符编码方法
时间:2011-03-24 编辑:简简单单 来源:一聚教程网
php教程判断页面输入字符编码方法
function convtoutf8($str)
{
if( mb_detect_encoding($str,"utf-8, iso-8859-1, gbk")!="utf-8" )
{return iconv("gbk","utf-8",$str);
}
else
{
return $str;
}}
?>
不过有朋友说,mb_detect_encoding函数不支持gbk只支持utf-8,utf-7,ascii,euc-jp,sjis,eucjp-win,sjis-win,jis,iso-2022-jp和iso-8859-*
各位可以测试,我没测试过。
/* detect character encoding with current detect_order */
echo mb_detect_encoding($str);
/* "auto" is expanded according to mbstring.language */
echo mb_detect_encoding($str, "auto");
/* specify encoding_list character encoding by comma separated list */
echo mb_detect_encoding($str, "jis, eucjp-win, sjis-win");
/* use array to specify encoding_list */
$ary[] = "ascii";
$ary[] = "jis";
$ary[] = "euc-jp";
echo
-
上一个: python 文件夹与文件操作实例
-
下一个: php 验证码详细生成与使用方法
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24