Warning: Undefined variable $UploadMaxSize in /home/kongdmdu/pmichaud/pmwiki/local/PITS.php on line 8

Warning: Undefined variable $UploadMaxSize in /home/kongdmdu/pmichaud/pmwiki/local/PITS.php on line 9

Warning: Undefined variable $UploadMaxSize in /home/kongdmdu/pmichaud/pmwiki/local/PITS.php on line 10

Warning: Undefined variable $UploadMaxSize in /home/kongdmdu/pmichaud/pmwiki/local/PITS.php on line 11

Warning: Undefined array key "pmwiki" in /home/kongdmdu/pmichaud/pmwiki/pub/skins/vector/vector.php on line 14

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/kongdmdu/pmichaud/pmwiki/pub/skins/vector/vector.php on line 14

Warning: Undefined array key "pagename" in /home/kongdmdu/pmichaud/pmwiki/pub/skins/vector/vector.php on line 225

Warning: Undefined array key "pagename" in /home/kongdmdu/pmichaud/pmwiki/pub/skins/vector/vector.php on line 253
00031: ucwords function does not work propely for some languages - PITS - PmWiki

00031: ucwords function does not work propely for some languages

Summary: ucwords function does not work propely for some languages
Created: 2004-09-06 04:43
Status: Closed - fixed
Category: Bug
From: Zverik
Assigned:
Priority: 5
Version: 1.0.8
OS: WinXP/Apache/4.1

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