|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-01-10 15:30 UTC] tony2001@php.net
[2007-03-22 22:39 UTC] nlopess@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 01:00:01 2025 UTC |
Description: ------------ when replacing an utf-8 string containing the character '?' (hex: c3a0) With the function preg_replace, and the pattern '\s', it changes the second byte of this character. Using the pattern '\t\f\r\n' which is supposed to be the same as \s it works perfectly. I have tried with other utf-8 characters and it seems to work. Reproduce code: --------------- <? $text = utf8_encode("this is a test ?t"); echo bin2hex($text)."\r\n"; $text1 = preg_replace("'([\t\f\r\n])+'", " ", $text); echo bin2hex($text1)."\r\n"; echo $text1."\r\n";; $text2 = preg_replace("'([\s])+'", " ", $text); echo bin2hex($text2)."\r\n"; echo $text2; ?> Expected result: ---------------- 746869732069732061207465737420c3a074 746869732069732061207465737420c3a074 this is a test ├?t 746869732069732061207465737420c3a074 this is a test ├?t Actual result: -------------- 746869732069732061207465737420c3a074 746869732069732061207465737420c3a074 this is a test ├?t 746869732069732061207465737420c32074 this is a test ├ t