ID: 37775
Updated by: [EMAIL PROTECTED]
Reported By: stronk7 at moodle dot org
-Status: Open
+Status: Bogus
Bug Type: PCRE related
Operating System: Windows XP
PHP Version: 5.1.4
New Comment:
such posix caracther classes depend on the current locale.
if you use setlocale() on the 3 machines with the same locale you'll
get the same results. (the definition of a control char is collected
from the iscntrl() system function)
Previous Comments:
------------------------------------------------------------------------
[2006-06-10 23:06:55] stronk7 at moodle dot org
Description:
------------
I was using one simple preg_replace() to clean strings from
control characters and, under XP I found that some utf-8
characters are also modified although they don't contain
control characters (\x-\1f and \7f) at all.
Same code seems to work properly under MacOS X and linux.
Please note that code below is utf-8 and should be pasted with
the editor in that mode. The char failing seems to be the
upper i with dieresis: Ï
The example include the non-working example (first) plus two
alternatives that work properly under XP.
Ciao :-)
Reproduce code:
---------------
<?php
$orig = "IIÏÏïï";
$dest = preg_replace("/[[:cntrl:]]/","",$orig);
echo $dest;
echo "\n<br>\n";
$orig = "IIÏÏïï";
$dest = ereg_replace("[[:cntrl:]]","",$orig);
echo $dest;
echo "\n<br>\n";
$orig = "IIÏÏïï";
$dest = preg_replace("/[\x-\x1f]/","",$orig);
echo $dest;
echo "\n<br>\n";
?>
Expected result:
----------------
Should return
IIÏÏïï
in the three alternatives.
Actual result:
--------------
This returns:
II??ïï <--- incorrect
<br>
IIÏÏïï <--- correct
<br>
IIÏÏïï <--- correct
<br>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37775&edit=1