s

utf8 체크하기

· 2013-03-23 (토) 22:27:56 · 3739
<?php
function check_utf8($str) {
$len = strlen($str);
for(
$i = 0; $i < $len; $i++){
$c = ord($str[$i]);
if (
$c > 128) {
if ((
$c > 247)) return false;
elseif (
$c > 239) $bytes = 4;
elseif (
$c > 223) $bytes = 3;
elseif (
$c > 191) $bytes = 2;
else return
false;
if ((
$i + $bytes) > $len) return false;
while (
$bytes > 1) {
$i++;
$b = ord($str[$i]);
if (
$b < 128 || $b > 191) return false;
$bytes--;
}
}
}
return
true;
}
// end of check_utf8
?>
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
14-10-13 조회 6,447
14-10-11 조회 6,642
14-10-11 조회 6,546
14-10-11 조회 6,434
14-10-10 조회 6,396
14-10-10 조회 6,250
14-10-08 조회 6,931
14-10-07 조회 6,350
14-10-06 조회 6,699
14-10-06 조회 7,488