ID: 43863
Updated by: [EMAIL PROTECTED]
Reported By: phprus at gmail dot com
-Status: Open
+Status: Assigned
Bug Type: Strings related
Operating System: OpenSuSE 10.2
PHP Version: 5.2.5
-Assigned To:
+Assigned To: tony2001
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