Project

General

Profile

Bug #20943 » cropMBString-trunk.patch

Administrator Admin, 2009-08-27 15:21

View differences:

class.t3lib_cs.php (working copy)
}
/**
* Method to crop strings using the mb_strimwidth function.
*
* @param string The character set
* @param string Character string
* @param integer Length (in characters)
* @param string Crop signifier
* @return string The shortened string
* @see mb_strimwidth(), mb_substr()
* @author Timo Schmidt <timo.schmidt@aoemedia.de>
*/
function cropMbstring($charset,$string,$len,$crop=''){
if (intval($len) == 0 || mb_strlen($string) < $len) return $string;
if($len > 0){
$string = mb_substr($string, 0, $len, $charset).$crop;
}else{
$string = $crop.mb_substr($string,$len,mb_strlen($string,$charset),$charset);
}
return $string;
}
/**
* Truncates a string and pre-/appends a string.
* Unit tested by Kasper
*
......
* @author Martin Kutschker <martin.t.kutschker@blackbox.net>
*/
function crop($charset,$string,$len,$crop='') {
if($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] == 'mbstring'){
return $this->cropMbstring($charset,$string,$len,$crop);
}
if (intval($len) == 0) return $string;
if ($charset == 'utf-8') {
(1-1/5)