|
Size: 967
Comment:
|
Size: 990
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 6: | Line 6: |
| [UTF8]사용자를 위한 문자열자르기 함수 변경 | [UTF8]사용자를 위한 문자열자르기 함수 변경 ( lib/common.lib.php ) |
[GNU]라이센스의 [APM] 게시판
http://sir.co.kr/gnuboard4.php
[UTF8]사용자를 위한 문자열자르기 함수 변경 ( lib/common.lib.php )
// 한글 한글자(2byte)는 길이 2, 공란.영숫자.특수문자는 길이 1
// UTF-8 을 위해 아래 함수 이용
/*
function cut_str($str, $len, $suffix="…")
{
$s = substr($str, 0, $len);
$cnt = 0;
for ($i=0; $i<strlen($s); $i++)
if (ord($s[$i]) > 127)
$cnt++;
$s = substr($s, 0, $len - ($cnt % 2));
if (strlen($s) >= strlen($str))
$suffix = "";
return $s . $suffix;
}
*/
function cut_str($str,$len,$tail='_') {
$c = substr(str_pad(decbin(ord($str{$len})),8,'0',STR_PAD_LEFT),0,2);
if ($c == '10')
for (;$c != '11' && $c{0} == 1;$c = substr(str_pad(decbin(ord($str{--$len})),8,'0',STR_PAD_LEFT),0,2));
return substr($str,0,$len) . (strlen($str)-strlen($tail) >= $len ? $tail : '');
}
BioHackersNet