Bug #79118 [Opn->Fbk]: mb_ereg_replace function cannot replace strings

From: Date: Wed, 15 Jan 2020 02:22:22 +0000
Subject: Bug #79118 [Opn->Fbk]: mb_ereg_replace function cannot replace strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224902@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 Updated by: requinix@php.net Reported by: minhlt82 at gmail dot com Summary: mb_ereg_replace function cannot replace strings -Status: Open +Status: Feedback Type: Bug -Package: Regexps related +Package: mbstring related Operating System: Linux PHP Version: 7.4.1 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#224902) next »