php - Why does `mb_eregi_replace` return NULL when the string contains extended ASCII codes? -
using php v7.1.5, why php function mb_eregi_replace
return null if string contains extended ascii code a0
("non-breaking space" according www.ascii-code.com)?
$ php -a interactive shell php > $t = mb_eregi_replace('d', '', "do\xa0not"); php > echo $t; php > if( $t === null ) { echo "is null"; } else { echo "replace worked"; } null php > $t = mb_eregi_replace('d', '', "do not"); php > echo $t; o not php > if( $t === null ) { echo "is null"; } else { echo "replace worked"; } replace worked
reading this article (specifically "what convert extended ascii utf-8" section) shows passing string utf8_encode
before passing mb_eregi_replace
solves problem.
$ php -a interactive shell php > $t = mb_eregi_replace('d', '', utf8_encode("do\xa0not")); php > echo $t; o not
Comments
Post a Comment