您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP判断字符串编码是否为utf8的函数

2024/6/6 10:39:24发布21次查看
无意中找到这么一段php判断字符串编码是否为utf8的函数,这个应该会用到的,保存下来存个档,这个是据称完美的判断函数,希望是完美的!
// returns true if $string is valid utf-8 and false otherwise. function is_utf8($word) { if (preg_match(/^([.chr(228).-.chr(233).]{1}[.chr(128).-.chr(191).]{1}[.chr(128).-.chr(191).]{1}){1}/,$word) == true || preg_match(/([.chr(228).-.chr(233).]{1}[.chr(128).-.chr(191).]{1}[.chr(128).-.chr(191).]{1}){1}$/,$word) == true || preg_match(/([.chr(228).-.chr(233).]{1}[.chr(128).-.chr(191).]{1}[.chr(128).-.chr(191).]{1}){2,}/,$word) == true) { return true; } else { return false; } } // function is_utf8
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product