php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21708 ucwords() trouble again
Submitted: 2003-01-17 03:49 UTC Modified: 2003-02-28 07:34 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: overseas at mtu-net dot ru Assigned:
Status: Closed Package: Strings related
PHP Version: 4.3.0 OS: Win 2000 Pro Russian + SP2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: overseas at mtu-net dot ru
New email:
PHP Version: OS:

 

 [2003-01-17 03:49 UTC] overseas at mtu-net dot ru
This bug only for Win32 =)

ucwords() function once again does not work properly with strings containing international characters.

Thus, any character following the "?"(ACSII code == 254) or "?"(ACSII code == 222) letter will always be uppercase.

Code:

<? 
setlocale(LC_CTYPE,"ru_RU.cp1251"); 

$str[] = "??????"; 
$str[] = "??????"; 
$str[] = "????????"; 
$str[] = "????????"; 
$str[] = "???????? =)"; 
$str[] = "????"; 
$str[] = "????"; 

for ($i=0;$i<sizeof($str);$i++) { 
    echo ucwords(strtolower($str[$i]))."<br>"; 
} 
?> 

Result:

?????? 
?????? 
???????? 
???????? 
???????? =) 
???? 
???? 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-17 04:18 UTC] overseas at mtu-net dot ru
Code:
<?
setlocale(LC_ALL,"ru_RU.cp1251");
$str = "???";
echo ucwords(strtolower($str));
?>

Result:

???
 [2003-01-17 04:50 UTC] moriyoshi@php.net
Try this:
setlocale(LC_CTYPE,"Russian.1251");

Windows locale string convension is different to *nix's.

See
http://msdn.microsoft.com/library/en-us/vccore98/html/_crt_language_and_country_strings.asp

for detail.

 [2003-01-17 15:12 UTC] overseas at mtu-net dot ru
Thank's. I tried to do this. No effect. =(

I think it can be feature of PHP under Win32 ;-)
 [2003-01-17 16:00 UTC] moriyoshi@php.net
Hmm, you can use mb_convert_case() instead if mbstring extension is enabled.

http://www.php.net/mb_convert_case

 [2003-01-28 04:43 UTC] richard dot cooling at coastdigital dot co dot uk
$text = '<script language="JavaScript" type="text/JavaScript">
alert ("this shouldnt be here");
</script>';

$text =strip_tags($text, $allowed_tags);

$text =ucfirst($text);
print $text;

PHP version 4.3 on win 32.

doesnt uppercase output

alert ("this shouldnt be here");
 [2003-02-09 10:45 UTC] moriyoshi@php.net
To overseas@mtu-net.ru:

Could you also try
setlocale(LC_CTYPE, "Russian_Russia.1251"?

 [2003-02-09 11:48 UTC] overseas at mtu-net dot ru
Yes. I tried to do it after reading your comment dated 17 Jan 4:50am (with link to MSDN). Output is wrong, but...
Every time starting of script containing 
setlocale (LC_CTYPE, "Russian_Russia.1251") I  have different (!!!) results... Interest, isn't it?
 [2003-02-09 11:52 UTC] overseas at mtu-net dot ru
FYI: MySQL (3.23.xx) under Win32 with 
character_set == cp1251
also have problem with LCASE, UCASE.
 [2003-02-18 12:16 UTC] moriyoshi@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

note: The fix will be available there in 8 hours.
 [2003-02-28 07:34 UTC] moriyoshi@php.net
Fix the summary

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 02:01:26 2024 UTC