count_str 에 관해 질문드립니다. 정보
count_str 에 관해 질문드립니다.본문
최신글을 밖으로 뺄때 한글과 영어를 카운트 하는 수가 서로 다르더군요...
count_str 를 사용하니.. 영어로 된 글일경우에는 한글로 작성된 글보다 길게 나오더군요...
영어랑 한글이랑 카운트 하는 숫자를 다르게 할 수 없나요??
count_str 를 사용하니.. 영어로 된 글일경우에는 한글로 작성된 글보다 길게 나오더군요...
영어랑 한글이랑 카운트 하는 숫자를 다르게 할 수 없나요??
댓글 전체
common.lib.php에서
function cut_str($str, $len, $suffix="")
{
global $g4;
$s = substr($str, 0, $len);
$cnt = 0;
for ($i=0; $i<strlen($s); $i++)
if (ord($s[$i]) > 127)
$cnt++;
if (strtoupper($g4['charset']) == 'UTF-8')
$s = substr($s, 0, $len - ($cnt % 3));
else
$s = substr($s, 0, $len - ($cnt % 2));
if (strlen($s) >= strlen($str))
$suffix = "";
return $s . $suffix;
}
를
function cut_str($str, $len, $suffix="")
{
global $g4;
$s = substr($str, 0, $len);
$cnt = 0;
for ($i=0; $i<strlen($s); $i++)
if (ord($s[$i]) > 127)
$cnt++;
if (strtoupper($g4['charset']) == 'UTF-8'){
if (CheckChar($s)==TRUE){
$s = substr($s, 0, ($len/1.8) - ($cnt % 3));
}else{
$s = substr($s, 0, $len - ($cnt % 3));
}
}else{
$s = substr($s, 0, $len - ($cnt % 2));
}
if (strlen($s) >= strlen($str))
$suffix = "";
return $s . $suffix;
}
// 영문인지 아닌지 판단
function CheckChar( $strChar ) {
// 글자를 바이너리 10000000 과 비트 AND연산후 10000000 이 되는지를 검사.
return ( ($strChar & chr(128)) == chr(128) ) ? FALSE : TRUE;
}
로 바꿔보세요
function cut_str($str, $len, $suffix="")
{
global $g4;
$s = substr($str, 0, $len);
$cnt = 0;
for ($i=0; $i<strlen($s); $i++)
if (ord($s[$i]) > 127)
$cnt++;
if (strtoupper($g4['charset']) == 'UTF-8')
$s = substr($s, 0, $len - ($cnt % 3));
else
$s = substr($s, 0, $len - ($cnt % 2));
if (strlen($s) >= strlen($str))
$suffix = "";
return $s . $suffix;
}
를
function cut_str($str, $len, $suffix="")
{
global $g4;
$s = substr($str, 0, $len);
$cnt = 0;
for ($i=0; $i<strlen($s); $i++)
if (ord($s[$i]) > 127)
$cnt++;
if (strtoupper($g4['charset']) == 'UTF-8'){
if (CheckChar($s)==TRUE){
$s = substr($s, 0, ($len/1.8) - ($cnt % 3));
}else{
$s = substr($s, 0, $len - ($cnt % 3));
}
}else{
$s = substr($s, 0, $len - ($cnt % 2));
}
if (strlen($s) >= strlen($str))
$suffix = "";
return $s . $suffix;
}
// 영문인지 아닌지 판단
function CheckChar( $strChar ) {
// 글자를 바이너리 10000000 과 비트 AND연산후 10000000 이 되는지를 검사.
return ( ($strChar & chr(128)) == chr(128) ) ? FALSE : TRUE;
}
로 바꿔보세요
와 감사합니다.. 직접 짜신건가요???