#43863 [Opn->Asn]: str_word_count and russian chars in locale cp1251

From: Date: Wed, 16 Jan 2008 08:29:35 +0000
Subject: #43863 [Opn->Asn]: str_word_count and russian chars in locale cp1251
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121328@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: 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 "&#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 this bug report at http://bugs.php.net/?id=43863&edit=1

« previous php.bugs (#121328) next »