#32958 [Fbk->Opn]: strtoupper/strtolower do not convert some 8859-2 characters
| From: | kirchner at cm-sec dot cz | Date: | Fri, 06 May 2005 06:36:14 +0000 |
| Subject: | #32958 [Fbk->Opn]: strtoupper/strtolower do not convert some 8859-2 characters | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-78689@lists.php.net to get a copy of this message | ||
ID: 32958
User updated by: kirchner at cm-sec dot cz
Reported By: kirchner at cm-sec dot cz
-Status: Feedback
+Status: Open
Bug Type: Strings related
Operating System: Linux Debian
PHP Version: 4.3.10
New Comment:
Hello,
you can be right. I used your test program and output is:
0000000 0aa9
0000002
When I convert 0xaa9 to dec = 2729 and I write in Linux console
<Alt>+<2729> I obtain the same character like when I write here
<Alt>+<169>, which is dec from 0xa9. Both outputs are correct.
When I change "str[0] to "str[0] = 0x61;" (letter "a") in main function
of your program, I obtain
0000000 0a41
0000002
Jan Kirchner
Previous Comments:
------------------------------------------------------------------------
[2005-05-05 20:21:44] rasmus@php.net
Sounds like a locale bug to me. Could you compile this test program?
#include <stdio.h>
#include <locale.h>
char *php_strtoupper(char *s, size_t len) {
unsigned char *c, *e;
c = s;
e = c+len;
while (c < e) {
*c = toupper(*c);
c++;
}
return s;
}
main(void) {
char str[2];
str[0] = 0xb9;
str[1] = 0x0;
setlocale(LC_ALL,"cs_CZ");
puts(php_strtoupper(str,1));
}
Just save it to s.c, for example and type: make s
Then run it like this: ./s | od -x
And add the output here.
As far as I can tell 0xb9 gets uppercased to 0xa9 in 8859-2, so you
should be seeing an a9 there in the output if your system's locale is
working correctly.
------------------------------------------------------------------------
[2005-05-05 17:34:51] kirchner at cm-sec dot cz
Description:
------------
Functions "strtolower" and "strtoupper" do not convert some Czech
characters from 8859-2 charset. I tested it and I found, that these
functions do not convert characters ""/"", ""/"" and
""/"", but
other special Czech characters are converted correctly.
Remark:
We most often use two charsets in our country: ISO 8859-2 for Unix like
systems and CP1250 (windows-1250) for Windows systems. Special Czech
characters have the same hexadecimal value in both charsets except of
mentioned characters (,,,,,).
I thing, that my locale is set correctly. Here are three rows from
output of the phpinfo() function.
default_charset ISO-8859-2 ISO-8859-2
_ENV["LC_ALL"] cs_CZ
_ENV["LANG"] cs_CZ
Best regards
Jan Kirchner
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32958&edit=1