4 十一月, 2004
Bug fixed: Messy codes when use string function "capitalize" on double-byte string
blueish模版,右边pannel中文title乱码
Bug: When we use blueish template, it showes pannel title on the right of the page. If we use local_zh_CN, the pannel titles are chinese. Capitalize these chinese words will make the sentence mess.
Fix: rewrite the capitalize function. see details below
file: class/template/smarty/plugins/modifier.capitalize.php
function smarty_modifier_capitalize($string)
{
//-- return ucwords($string);
$strarr = explode(" ", $string);
$i = 0;
while( $i < count($strarr) )
{
$w = $strarr[$i];
if($w && Ord($w)<128)
$strarr[$i] = ucfirst($w);
$i++;
}
return implode(" ", $strarr);
}
Problems: capitalize is not a build-in function, but php4 does offer this function, it's realized with C codes. It uses toupper() to make the first char uppercase. toupper is locale sensitive function, when it deals with chinese string, the error occurs.
I'm absolutely PHP newbie. There must exist a much better way to resolve this problem, and, perhaps what I updated will bring other unknown new bugs.



