#43863 [NEW]: str_word_count and russian chars in locale cp1251

From: Date: Wed, 16 Jan 2008 07:59:23 +0000
Subject: #43863 [NEW]: str_word_count and russian chars in locale cp1251
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121326@lists.php.net to get a copy of this message
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 "&#1103;" 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('&#1088;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081; &#1090;&#1077;&#1082;&#1089;&#1090;. &#1103; &#1090;&#1077;&#1089;&#1090;&#1077;&#1088;. &#1072;&#1103;&#1073;&#1072;&#1075;. &#1103;&#1072;&#1087;. &#1072;&#1074;&#1103;', 2)); ?> Expected result: ---------------- array(7) { [0]=> string(7) "&#1088;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;" [8]=> string(5) "&#1090;&#1077;&#1082;&#1089;&#1090;" [15]=> string(1) "&#1103;" [17]=> string(6) "&#1090;&#1077;&#1089;&#1090;&#1077;&#1088;" [25]=> string(5) "&#1072;&#1103;&#1073;&#1072;&#1075;" [32]=> string(3) "&#1103;&#1072;&#1087;" [37]=> string(3) "&#1072;&#1074;&#1103;" } Actual result: -------------- array(7) { [0]=> string(7) "&#1088;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;" [8]=> string(5) "&#1090;&#1077;&#1082;&#1089;&#1090;" [17]=> string(6) "&#1090;&#1077;&#1089;&#1090;&#1077;&#1088;" [25]=> string(1) "&#1072;" [27]=> string(3) "&#1073;&#1072;&#1075;" [33]=> string(2) "&#1072;&#1087;" [37]=> string(2) "&#1072;&#1074;" } -- 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

« previous php.bugs (#121326) next »