Author Topic: Some multibyte improvements  (Read 1163 times)

lysov

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 105
    • Litera ltd
Some multibyte improvements
« on: December 29, 2011, 15:33:36 pm »
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:
Code: [Select]
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10000
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Some multibyte improvements
« Reply #1 on: December 29, 2011, 16:28:56 pm »
Is implemented, thx
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/