Req #75225 [Com]: Add mb_str_replace/mb_str_ireplace
| From: | 1234ru at gmail dot com | Date: | Fri, 29 Sep 2017 22:28:21 +0000 |
| Subject: | Req #75225 [Com]: Add mb_str_replace/mb_str_ireplace | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211470@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75225&edit=1
ID: 75225
Comment by: 1234ru at gmail dot com
Reported by: 1234ru at gmail dot com
Summary: Add mb_str_replace/mb_str_ireplace
Status: Open
Type: Feature/Change Request
Package: mbstring related
PHP Version: 7.1.9
Block user comment: N
Private report: N
New Comment:
> spam2 at rhsoft dot net
> this is NOT a bug - most of the string funtion don't work for UTF8
> http://php.net/manual/en/book.mbstring.php
Yes. But there is no mb_str_replace().
> str_ireplace() regards the currently set locale, see
> <https://3v4l.org/AaXAm>,
> but apparently that is not mentioned in the documentation.
Yes. That's the very problem. str_replace() works with no explicit LC_ALL setting, but
str_ireplace() doesn't. That is rather misleading. I guess this should be mentioned in the
docs.
Previous Comments:
------------------------------------------------------------------------
[2017-09-18 14:33:21] cmb@php.net
str_ireplace() regards the currently set locale, see <https://3v4l.org/AaXAm>,
but apparently that is not mentioned in the documentation.
------------------------------------------------------------------------
[2017-09-18 14:29:03] requinix@php.net
Virtually all of the regular string functions are not for multibyte encodings.
------------------------------------------------------------------------
[2017-09-18 14:28:23] spam2 at rhsoft dot net
this is NOT a bug - most of the string funtion don't work for UTF8 at all and be warned about
making decisions about strlen() on UTF8 strings
http://php.net/manual/en/book.mbstring.php
------------------------------------------------------------------------
[2017-09-18 14:27:12] 1234ru at gmail dot com
An actual example is this:
echo str_ireplace("Ð", "1", "ÐÐÐббб");
// yelds 111ббб instead of 111111
(It doesn't allow me to edit the bug description so I post it as a comment.)
------------------------------------------------------------------------
[2017-09-18 14:20:25] 1234ru at gmail dot com
Description:
------------
In other words, it simply ignores case-insensitive replacement when dealing with any letters except
Latin.
Not a single word in the documentation at http://php.net/str_ireplace covers the issue.
And there is no corresponding mb* function.
Test script:
---------------
echo str_ireplace("б", "1", "111ббб"); // russian letters
in UTF-8 encoding
Expected result:
----------------
111111
Actual result:
--------------
111ббб
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75225&edit=1