News:

Looking for documentation? Take a look on our wiki

Main Menu

Some multibyte improvements

Started by lysov, December 29, 2011, 15:33:36 PM

Previous topic - Next topic

lysov

I would like to use multibyte functions to improve the support national languages. The function limitStringByWord from components/com_virtuemart/helpers/shopfunctionsf.php works incorrect with russians words. A small improvement can be done here:
public function limitStringByWord($string, $maxlength, $suffix=''){
if(function_exists('mb_strlen')) { /* use multibyte functions */
if(mb_strlen($string)<=$maxlength) return $string;
$string = mb_substr($string,0,$maxlength);
$index = mb_strrpos($string, ' ');
if($index===FALSE) {
return $string;
} else {
return mb_substr($string,0,$index).$suffix;
}
} else { /* original code here */
if(strlen($string)<=$maxlength) return $string;
$string = substr($string,0,$maxlength);
$index = strrpos($string, ' ');
if($index===FALSE) {
return $string;
} else {
return substr($string,0,$index).$suffix;
}
}
}

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/