Bug #79118 [Com]: mb_ereg_replace function cannot replace strings
| From: | minhlt82 at gmail dot com | Date: | Wed, 15 Jan 2020 03:29:02 +0000 |
| Subject: | Bug #79118 [Com]: mb_ereg_replace function cannot replace strings | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224903@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79118&edit=1
ID: 79118
Comment by: minhlt82 at gmail dot com
Reported by: minhlt82 at gmail dot com
Summary: mb_ereg_replace function cannot replace strings
Status: Feedback
Type: Bug
Package: mbstring related
Operating System: Linux
PHP Version: 7.4.1
Block user comment: N
Private report: N
New Comment:
@Requinix:
Thank you for the super fast support.
For the replacement of the binary string, following your link https://3v4l.org/ofV7G I am still facing a problem that the hex
value of binary string before and after the conversion (by mb_convert_encoding)is changed from f8f7
to 3fc3b7.
Could you please help me to check here https://3v4l.org/JE5r8
Thank you so much.
Previous Comments:
------------------------------------------------------------------------
[2020-01-15 02:22:22] requinix@php.net
Seems to be working fine.
https://3v4l.org/Z575v
https://3v4l.org/ofV7G
Because you can't pass raw binary data to something that operates on characters.
------------------------------------------------------------------------
[2020-01-15 02:00:31] minhlt82 at gmail dot com
Description:
------------
The mb_ereg_replace function cannot replace strings that contain some characters with the SJIS
encoding. In these cases, the result is NULL.
It works well with PHP versions < 7.1 but fails with PHP 7.1 and above.
Test script:
---------------
mb_regex_encoding('SJIS');
$string = "hello ããã«æãå
¥ããã";
$pattern = "hello";
$replacement = 'hi';
//expected result: hi ããã«æãå
¥ããã
//but it returns NULL
var_dump(mb_ereg_replace($pattern, $replacement, $string));
//Similar error for binary strings, you can test more here.
//http://sandbox.onlinephpfunctions.com/code/1a741afb48b299c6f335d9175be730a5ec3854d5
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79118&edit=1