From: phprus at gmail dot com Operating system: OpenSuSE 10.2 PHP version: 5.2.5 PHP Bug Type: Strings related Bug description: str_word_count and russian chars in locale cp1251
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 bug report at http://bugs.php.net/?id=43863&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43863&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43863&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43863&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43863&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43863&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43863&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43863&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43863&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43863&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43863&r=support Expected behavior: http://bugs.php.net/fix.php?id=43863&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43863&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43863&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43863&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43863&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43863&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43863&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43863&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43863&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43863&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43863&r=mysqlcfg