|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-10-22 16:14 UTC] mjong at magnafacta dot nl
Description:
------------
Using strtoupper, ms_strtoupper and derived functions like ucfirst
produced incorrectly encoded strings when used on strings containing
Japanese Hirigana or Katakana characters.
As no uppercase versions of these characters exists they should be
treated as e.g. numbers.
Workaround: use mb_check_encoding to revert to the old string when this
happens.
Reproduce code:
---------------
// $s = strtoupper('まてえす and ジョング');
$s = strtoupper(
base64_decode('44Gm44GI44GZ').
' and '.
base64_decode('44K444On44Oz44Kw'));
if (mb_check_encoding($s)) {
echo $s;
} else {
echo 'Error';
}
Expected result:
----------------
まてえす and ジョング
Actual result:
--------------
Error
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 09:00:01 2025 UTC |
Description: ----------- I actually just encountered this problem as well with ucfirst() but not mb_strtoupper(). I would not even comment except that PHP 5.3.8 fails on using ucfirst() whereas 5.3.6 succeeds. As such, my code that had worked previously had stopped working before I put in a workaround using mb_strtoupper(). I do not know if PHP considers this to be a problem or not, since technically the software writer should not have used ucfirst() to begin with. However, it seems like a problem to me when an ostensibly minor update has the result of unnecessarily breaking code. It did not work properly on two system I used, and did work properly on one system. Systems I tried: *did NOT work - PHP 5.3.8 (cli) (built: Aug 23 2011 12:14:39) *did NOT work - PHP 5.3.8 (cli) (built: Nov 8 2011 22:18:15) (custom build, IIRC) *worked properly - PHP 5.3.6-13ubuntu3.2 with Suhosin-Patch (cli) (built: Oct 13 2011 23:09:42) Reproduce code: --------------- echo ucfirst(urldecode("%E6%97%A5%E5%85%89%E6%9D%B1%E7%85%A7%E5%AE%AE%E9%99%BD%E6%98%8E%E9%96%80")); Expected result: 日光東照宮陽明門 Result given in failing versions above: Ɨ�光東照宮陽明門