|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79986 str_ireplace bug with diacritics characters
Submitted: 2020-08-17 18:03 UTC Modified: 2020-08-18 11:31 UTC
From: cryptooman at yandex dot ru Assigned: cmb (profile)
Status: Closed Package: Strings related
PHP Version: 7.2.33 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cryptooman at yandex dot ru
New email:
PHP Version: OS:


 [2020-08-17 18:03 UTC] cryptooman at yandex dot ru
From manual page:
Function str_ireplace fails to replace diacritics characters if case (lower or upper) of search pattern does not match case of characters in subject string. Affected languages: french, russian, german, spanish, etc. Short php-script sample provided below.

Test script:
// French
// Result: 1À 2Â 3Ä 4Æ
// Expect: 11 22 33 44
echo str_ireplace(['à', 'â', 'ä', 'æ'], ['1', '2', '3', '4'], 'àÀ â äÄ æÆ') . PHP_EOL;
// Result: à1 â2 ä3 æ4
// Expect: 11 22 33 44
echo str_ireplace(['À', 'Â', 'Ä', 'Æ'], ['1', '2', '3', '4'], 'àÀ â äÄ æÆ') . PHP_EOL;

// Russian
// Result: 1Ё 2Й
// Expect: 11 22
echo str_ireplace(['ё', 'й'], ['1', '2'], 'ёЁ йЙ') . PHP_EOL;
// Result: ё1 й2
// Expect: 11 22
echo str_ireplace(['Ё', 'Й'], ['1', '2'], 'ёЁ йЙ') . PHP_EOL;


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-18 10:19 UTC]
-Status: Open +Status: Verified -Package: *General Issues +Package: Strings related
 [2020-08-18 10:19 UTC]
Actually, str_ireplace() (like several other string functions) is
supposed to be locale aware, but only supporting single byte
locales properly; this is not documented yet.

The implementation doesn't match that expectation, though[1].

Anyhow, assuming that you're dealing with UTF-8, you may want to
use preg_replace() instead[2].

[1] <>
[2] <>
 [2020-08-18 11:29 UTC]
-Assigned To: +Assigned To: cmb
 [2020-08-18 11:30 UTC]
The following pull request has been associated:

Patch Name: Fix #79986: str_ireplace bug with diacritics characters
On GitHub:
 [2020-08-18 11:31 UTC]
-Operating System: Ubuntu 18.04 +Operating System: *
 [2020-08-24 09:10 UTC]
Automatic comment on behalf of
Log: Fix #79986: str_ireplace bug with diacritics characters
 [2020-08-24 09:10 UTC]
-Status: Verified +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Feb 27 13:01:27 2024 UTC