00031: ucwords function does not work propely for some languages
Description: It's written in the PHP Manual, in the discussion of ucwords function. On some languages, e.g. Russian, this function uppercases letters in the middle of words. Suggested fix:
function ucwords_fix($string) { $temp = preg_split('/(\W)/', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
foreach ($temp as $key=>$word) {
$temp[$key] = ucfirst(strtolower($word));
}
return join ('', $temp);
}
This function is used once in pmwiki.php and once in search.php. I've changed it for my version, but it'll be erased after the next PmWiki upgrade.
Hmm. How about this instead?
function ucwords_fix($string) { return preg_replace('/\\b(\\w)/e',"strtoupper('$1')",$string); }
This simply capitalizes any word character that is not preceded by another word character. Seems like this would be shorter+more efficient. --Pm
That code also works correctly, thanx. And looks better :) --Zverik
In v1, I changed pmwiki.php to use the preg_replace() above instead of ucwords(), and got rid of ucwords() from search.php (it's a case-insensitive search so it doesn't matter). Should appear in 1.0.9.
Also fixed this bug in v2. --PmPm