|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14655 ucwords failing randomly with international characters
Submitted: 2001-12-21 22:32 UTC Modified: 2002-12-25 02:30 UTC
Avg. Score:4.2 ± 0.8
Reproduced:3 of 4 (75.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: xtango at netcombbs dot com dot ar Assigned: hholzgra (profile)
Status: Closed Package: Strings related
PHP Version: 4.1.0 OS: Windows XP Pro (spanish)
Private report: No CVE-ID: None
 [2001-12-21 22:32 UTC] xtango at netcombbs dot com dot ar


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-23 15:51 UTC]
To me this sounds like a system problem. PHP only uses the
systems notion of upper and space. When the character
following the international character it is probably
because the international character is treated as a
space by the system (isspace() returning true). It's quite
weird that the results are not consistent. The PHP function
itself is quite straightforward, so I suspect the locale is
not the same every time, or that the systems isspace() and
possibly toupper() is broken. I can't say for sure though.

 [2002-01-22 08:03 UTC] martin at humany dot com

 [2002-04-21 06:24 UTC] bs_php at infeer dot com
Confirming your bug (PHP 4.1.2 on W2k)
setlocale() on windows is the problem!
See bug #16718
 [2002-06-17 07:02 UTC]
setlocale() doesn't work well with multithreaded servers
as the current locale is set globaly for all threads
 [2002-07-13 18:10 UTC]
chancing status
 [2002-08-27 07:50 UTC] fille at fukt dot bth dot se
I had this bug to. To get around it, I added some 'hair' to the code.

//Bugfix from here on
	if((ctype_upper($string[$i]) &&( $string[$i-1]==" " || $i==0 ))!=TRUE)

I'm a PHP newbie so I guess some of you can come up with a brighter solution. This code lowercases _all_ letters that is not either the first in the string or following a space. If your application does not meet both this criterias, you might not want this code.
 [2002-12-21 09:49 UTC]
You can use mb_convert_case() instead of ucwords.
Could I close this bug?

 [2002-12-23 10:15 UTC] xtango at netcombbs dot com dot ar
Somebody said that this is a problem with setlocale (Windows) and not with ucwords. This issue is beign debated in 14655 and 16718. Also, mb_convert_case() seems to be safe.
I guess this bug can be closed.
 [2002-12-25 02:30 UTC]
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC