1. // 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

posted on 2013-04-23 16:42  Right_MR  阅读(184)  评论(0编辑  收藏  举报