#45438 [Opn]: mb_eregi finds space

From: Date: Fri, 01 Aug 2008 23:23:40 +0000
Subject: #45438 [Opn]: mb_eregi finds space
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1044@lists.php.net to get a copy of this message
ID: 45438 Updated by: moriyoshi@php.net Reported By: hayk at mail dot ru Status: Open -Bug Type: mbstring related +Bug Type: Documentation problem Operating System: CentOS 5.1 (x64) PHP Version: 5.2.6 New Comment: mb_internal_encoding() doesn't reset the regex encoding that is settable by mb_regex_encoding() in contrast to the ini setting "mbstring.internal_encoding". This is really confusing and should have been documented somewhere. Try the following code with any one of the numbered portions uncommented to see the difference: <?php // (1) // mb_internal_encodnig('UTF-8'); // (2) // mb_internal_encoding('UTF-8'); mb_regex_encoding('UTF-8'); // (3) // ini_set('mbstring.internal_encoding', 'UTF-8'); var_dump(mb_internal_encoding()); var_dump(mb_regex_encoding()); $x = "\xd0\x9f\xd0\xa0\xd0\x98\xd0\xa0\xd0\x9e\xd0\x94\xd0\x90"; $r = mb_eregi('^([^[:space:]]+([[:space:]][ivx]+)?)(.*)$', $x, $m); var_dump($r, $m); ?> Previous Comments: ------------------------------------------------------------------------ [2008-07-06 10:17:12] hayk at mail dot ru Description: ------------ Sometimes mb_eregi finds space in the string when string in utf-8 and contains Russian capitalized "&#1056;" (chr(0xD0) . chr(0xA0) in utf-8, it's not English "P"). Reproduce code: --------------- <?php mb_internal_encoding('UTF-8'); header('Content-Type: text/html; charset=utf-8'); $x = '&#1055;&#1056;&#1048;&#1056;&#1054;&#1044;&#1040;'; //$x = chr(0xD0) . chr(0x9F) . chr(0xD0) . chr(0xA0) . chr(0xD0) . chr(0x98) . chr(0xD0) . chr(0xA0) . chr(0xD0) . chr(0x9E) . chr(0xD0) . chr(0x94) . chr(0xD0) . chr(0x90); $r = mb_eregi('^([^[:space:]]+([[:space:]][ivx]+)?)(.*)$', $x, $m); print_r($m); ?> Expected result: ---------------- Array ( [0] => &#1087;&#1088;&#1080;&#1088;&#1086;&#1076;&#1072; [1] => &#1087;&#1088;&#1080;&#1088;&#1086;&#1076;&#1072; [2] => [3] => ) Actual result: -------------- Array ( [0] => &#1055;&#1056;&#1048;&#1056;&#1054;&#1044;&#1040; [1] => &#1055;&#65533; [2] => [3] => &#65533;&#1048;&#1056;&#1054;&#1044;&#1040; ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45438&edit=1

« previous php.doc.bugs (#1044) next »