background image

$count ;
if($value>= 192 && $value <= 223) $i ;
elseif($value>= 224 && $value <= 239) $i = $i 2;
elseif($value>= 240 && $value <= 247) $i = $i 3;
else die(‘Not a UTF-8 compatible string’);
}
$count ;
 
}
return(substr($str,$start_position,$end_position-$start_position));
}
 
 
//字符串长度统计-UTF8 [中文 3 个字节,俄文、韩文占 2 个字节,字母占 1 个字节] 
(Ruby)
def utf8_string_length(str)
temp = CGI::unescape(str)
i = 0;
j = 0;
temp.length.times{|t|
if temp[t] <127
i = 1
elseif temp[t]>= 127 and temp[t] <224
j = 1
if 0 == (j % 2)
i = 2
j = 0
end
else
j = 1
if 0 == (j % 3)
i =2
j = 0
end
end
}
return i
}
 
//判断是否是有韩文-UTF-8 (JavaScript)
function checkKoreaChar(str) {
for(i=0; i<str.length; i ) {