// 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
PHP判断字符串编码是否为utf8的函数
http://it.oyksoft.com/post/49/
猜你喜欢
转载自panyongzheng.iteye.com/blog/1168025
今日推荐
周排行