Skip to content

Instantly share code, notes, and snippets.

@ophentis
Created June 21, 2011 03:43
Show Gist options
  • Save ophentis/1037197 to your computer and use it in GitHub Desktop.
Save ophentis/1037197 to your computer and use it in GitHub Desktop.
php multibyte truncate (chineese)
if(mb_strlen($string,$charset) > $length) {
$string = mb_substr($string,0,$length,$charset);
return preg_replace('/(\p{Mc}|\p{Zl})+$/u','',$string).$suffix;
} else {
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment