#43863 [Asn->Csd]: str_word_count and russian chars in locale cp1251
| From: | tony2001@php.net | Date: | Wed, 16 Jan 2008 08:36:19 +0000 |
| Subject: | #43863 [Asn->Csd]: str_word_count and russian chars in locale cp1251 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-121329@lists.php.net to get a copy of this message | ||
ID: 43863
Updated by: tony2001@php.net
Reported By: phprus at gmail dot com
-Status: Assigned
+Status: Closed
Bug Type: Strings related
Operating System: OpenSuSE 10.2
PHP Version: 5.2.5
Assigned To: tony2001
New Comment:
This bug has been fixed in CVS.
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/.
Thank you for the report, and for helping us make PHP better.
Patch committed, thanks.
Previous Comments:
------------------------------------------------------------------------
[2008-01-16 07:59:23] phprus at gmail dot com
Description:
------------
str_word_count return wrong number, if char "я" is
contained in the word.
Problem code (in file ext/standard/string.c):
while (p < e && (isalpha(*p) || (char_list && ch[(unsigned char)*p]) ||
*p == '\'' || *p == '-')) {
Corrected code:
while (p < e && (isalpha((unsigned char)*p) || (char_list &&
ch[(unsigned char)*p]) || *p == '\'' || *p == '-')) {
Description of bug fixes in Russian language:
http://phpclub.ru/talk/showthread.php?postid=746475#post746475
Reproduce code:
---------------
<?php
setlocale(LC_ALL, 'ru_RU.cp-1251', 'ru_RU.CP1251');
var_dump(str_word_count('русский
текст. я
тестер.
аябаг. яап.
авя', 2));
?>
Expected result:
----------------
array(7) {
[0]=>
string(7)
"русский"
[8]=>
string(5) "текст"
[15]=>
string(1) "я"
[17]=>
string(6) "тестер"
[25]=>
string(5) "аябаг"
[32]=>
string(3) "яап"
[37]=>
string(3) "авя"
}
Actual result:
--------------
array(7) {
[0]=>
string(7)
"русский"
[8]=>
string(5) "текст"
[17]=>
string(6) "тестер"
[25]=>
string(1) "а"
[27]=>
string(3) "баг"
[33]=>
string(2) "ап"
[37]=>
string(2) "ав"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43863&edit=1