#37775 [NEW]: [[cntrl]] class seems to kill some utf-8 strings...
| From: | stronk7 at moodle dot org | Date: | Sat, 10 Jun 2006 23:06:55 +0000 |
| Subject: | #37775 [NEW]: [[cntrl]] class seems to kill some utf-8 strings... | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-98263@lists.php.net to get a copy of this message | ||
From: stronk7 at moodle dot org
Operating system: Windows XP
PHP version: 5.1.4
PHP Bug Type: PCRE related
Bug description: [[cntrl]] class seems to kill some utf-8 strings...
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 bug report at http://bugs.php.net/?id=37775&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37775&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37775&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37775&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37775&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37775&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37775&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37775&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37775&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37775&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37775&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37775&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37775&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37775&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37775&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37775&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37775&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37775&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37775&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37775&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37775&r=mysqlcfg