Bug #77093 [Nab]: mb_ereg_replace() does not work with SJIS-win(cp932)

From: Date: Fri, 02 Nov 2018 09:17:44 +0000
Subject: Bug #77093 [Nab]: mb_ereg_replace() does not work with SJIS-win(cp932)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217793@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77093&edit=1 ID: 77093 User updated by: ryosuke dot kobayashi at fujisystems dot co dot jp Reported by: ryosuke dot kobayashi at fujisystems dot co dot jp Summary: mb_ereg_replace() does not work with SJIS-win(cp932) Status: Not a bug Type: Bug Package: mbstring related Operating System: Linux PHP Version: 7.2.11 Block user comment: N Private report: N New Comment: Thank you for your reply. >You need to use mb_regex_encoding() to specify the mb_regex encoding. Exactry... I forgotted to add this cuz my Environment works on SJIS-win. I fixed my test code, and tried it here. https://3v4l.org/m6JZe Now, the problem has occurd I wanted to point out. Best regards. Previous Comments: ------------------------------------------------------------------------ [2018-11-02 08:06:14] yohgaki@php.net Mbstring's internal and regex encoding is independent. Before 5.6/7.0, mbregex's default encoding was EUC-JP which ISO 8859-1 compatible. So it worked in most cases. Since 5.6/7.0, I made default to UTF-8. https://wiki.php.net/rfc/default_encoding Anyway, to make sure correct operations, you'll need to set correct encoding via mb_regex_encoding() for mb_ereg*(). I might have to take a look at where the difference came from, though. If you notice anything wrong, please let us know. ------------------------------------------------------------------------ [2018-11-02 07:53:27] yohgaki@php.net You need to use mb_regex_encoding() to specify the mb_regex encoding. https://3v4l.org/SYRJP ------------------------------------------------------------------------ [2018-11-02 01:32:48] ryosuke dot kobayashi at fujisystems dot co dot jp Description: ------------ mb_ereg_replace() just returns null when given string contains some specific characters in 'SJIS-win' (e.g. 'ⅰ', '伃'...), and it works without output errors. Between 0xFA40('ⅰ') and 0xFC4B('黑') causes this bug, imo. It also happens with mb_ereg_match*(). I confirmed that this happens PHP Version 7.1 or higher. Here's a results I tried. PHP 7.0.32 with oniguruma 5.9.6 => It works. PHP 7.0.32 with oniguruma 6.3.0 => It works. PHP 7.1.23 with oniguruma 5.9.6 => It does not work. PHP 7.2.11 with oniguruma 6.3.0 => It does not work. Test script: --------------- function chk($a,$b){ mb_internal_encoding('SJIS-win'); $j=0; for($i=$a;$i<$b;$i++){ $s=sprintf('%x',$i); $hex = hex2bin($s); if(mb_check_encoding($hex)){ if (!mb_ereg($hex, $hex)){ echo "$s($hex):NG\n"; } }else{ } $j++; } echo "cnt:$j\n"; } chk(0xED40,0xFC51); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77093&edit=1

« previous php.bugs (#217793) next »