Bug #79986 [PATCH]: str_ireplace bug with diacritics characters

From: Date: Tue, 18 Aug 2020 11:30:21 +0000
Subject: Bug #79986 [PATCH]: str_ireplace bug with diacritics characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228639@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79986&edit=1 ID: 79986 Patch added by: cmb@php.net Reported by: cryptooman at yandex dot ru Summary: str_ireplace bug with diacritics characters Status: Verified Type: Bug Package: Strings related Operating System: Ubuntu 18.04 PHP Version: 7.2.33 Assigned To: cmb Block user comment: N Private report: N New Comment: The following pull request has been associated: Patch Name: Fix #79986: str_ireplace bug with diacritics characters On GitHub: https://github.com/php/php-src/pull/6007 Patch: https://github.com/php/php-src/pull/6007.patch Previous Comments: ------------------------------------------------------------------------ [2020-08-18 10:19:12] cmb@php.net 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] <https://3v4l.org/GVECA> [2] <https://3v4l.org/2D4ZJ> ------------------------------------------------------------------------ [2020-08-17 18:03:50] cryptooman at yandex dot ru Description: ------------ --- From manual page: https://php.net/function.str-ireplace --- 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: --------------- <?php // 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; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79986&edit=1

« previous php.bugs (#228639) next »