<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_34880"> <img alt="문자열이 UTF8로 인코딩되었는지 확인하세요." src="http://img.it-home.org/data/attachment/forum/2014pic/16195715_kPci.png">转载地址: http://blog.qita.in/?post=418 <div class="blockcode"> <div id="code_bjp"><ol> <li>function is_utf8($string){</li> <li> return preg_match('%^(?:</li> <li> [x09x0Ax0Dx20-x7E] # ASCII</li> <li> | [xC2-xDF][x80-xBF] # non-overlong 2-byte</li> <li> | xE0[xA0-xBF][x80-xBF] # excluding overlongs</li> <li> | [xE1-xECxEExEF][x80-xBF]{2} # straight 3-byte</li> <li> | xED[x80-x9F][x80-xBF] # excluding surrogates</li> <li> | xF0[x90-xBF][x80-xBF]{2} # planes 1-3</li> <li> | [xF1-xF3][x80-xBF]{3} # planes 4-15</li> <li> | xF4[x80-x8F][x80-xBF]{2} # plane 16</li> <li> )*$%xs', $string);</li> <li>}</li> </ol></div> <em onclick="copycode($('code_bjp'));">复制代码</em> </div> </td></tr></table> <div id="comment_34880" class="cm"> </div> <div id="post_rate_div_34880"></div> <br><br>