Bug #79617 [Nab]: mb_convert_case() with MB_CASE_TITLE unexpected behavior for second characters

From: Date: Thu, 21 May 2020 19:59:41 +0000
Subject: Bug #79617 [Nab]: mb_convert_case() with MB_CASE_TITLE unexpected behavior for second characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227119@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79617&edit=1 ID: 79617 Updated by: nikic@php.net Reported by: dedienaar+phpnet at gmail dot com Summary: mb_convert_case() with MB_CASE_TITLE unexpected behavior for second characters Status: Not a bug Type: Bug Package: *Unicode Issues Operating System: Ubuntu 18.04.4 LTS PHP Version: 7.2.31 Assigned To: nikic Block user comment: N Private report: N New Comment: For reference, the relevant fix in 7.3 was https://github.com/php/php-src/commit/f4a1d9c8211fa7878af14d0bd94b2deaab19ae21. Previous Comments: ------------------------------------------------------------------------ [2020-05-21 19:52:31] nikic@php.net I rewrote title case folding in PHP 7.3, and as far as I can see everything folds correctly there: https://3v4l.org/8I587 Please use a recent version of PHP. ------------------------------------------------------------------------ [2020-05-21 18:09:46] girgias@php.net I'm assigning this to Nikita just to double check but this seems to me not be a bug. Copy pasting the character which you are indicating to be a quotation mark (in which case it should indeed capitalize the first letter) into google I come up with the code point for "Modifier Letter Right Half Ring" (U+02BE) which is not a quotation mark and is meant to modify the previous code-point. Thus the string is not valid UTF-8 from what my limited knowledge about it. And the behaviour is totally expected. Moreover, a single apostrophe/quotation mark MUST NOT capitalize the letter after it otherwise we would get stupid text such as "Isn'T valid" which is and should be "Isn't" The backtick follows the same principle you can't just have a single one and expect it to recognize it as a possible quotation mark (which is already highly debatable) ------------------------------------------------------------------------ [2020-05-21 17:41:09] dedienaar+phpnet at gmail dot com Description: ------------ This relates to: - https://www.php.net/manual/en/function.mb-convert-case - https://github.com/php/php-src/blob/35e0a91db717fe441a89ca9554d8843d8ee63112/ext/mbstring/mbstring.c#L2674-L2709 - https://github.com/laravel/framework/issues/32910 The function mb_convert_case() unfortunately does not take apostrophes, quotes and certain other special characters into consideration when converting case using MB_CASE_TITLE. Test script: --------------- >>> var_dump(mb_convert_case('al-fātiḥah', MB_CASE_TITLE, >>> 'UTF-8')); => string(13) "Al-Fātiḥah" // <-- GOOD >>> var_dump(mb_convert_case('AL-FĀTIḤAH', MB_CASE_TITLE, >>> 'UTF-8')); => string(13) "Al-Fātiḥah" // <-- GOOD >>> var_dump(mb_convert_case('ʾāli-ʿimrān', MB_CASE_TITLE, >>> 'UTF-8')); => string(15) "ʾāli-ʿimrān" // <-- NOT GOOD: Not uppercased 'Ā' and 'I' due to preceding ʾ and ʿ >>> var_dump(mb_convert_case('ʾĀLI-ʿIMRĀN', MB_CASE_TITLE, >>> 'UTF-8')); => string(15) "ʾāli-ʿimrān" // <-- NOT GOOD: Lowercased 'Ā' and 'I' due to preceding ʾ and ʿ >>> var_dump(mb_convert_case('aṣ-ṣāffāt', MB_CASE_TITLE, >>> 'UTF-8')); => string(15) "Aṣ-Ṣāffāt" // GOOD >>> var_dump(mb_convert_case('AṢ-ṢĀFFĀT', MB_CASE_TITLE, >>> 'UTF-8')); => string(15) "Aṣ-Ṣāffāt" // GOOD >>> var_dump(mb_convert_case('ṭāʾ hāʾ', MB_CASE_TITLE, >>> 'UTF-8')); => string(13) "Ṭāʾ Hāʾ" // GOOD >>> var_dump(mb_convert_case('ṬĀʾ HĀʾ', MB_CASE_TITLE, >>> 'UTF-8')); => string(13) "Ṭāʾ Hāʾ" // GOOD >>> var_dump(mb_convert_case('ʾibrāhīm', MB_CASE_TITLE, >>> 'UTF-8')); => string(11) "ʾibrāhīm" // <-- NOT GOOD: Lowercased 'I' due to preceding ʾ >>> var_dump(mb_convert_case('ʾIBRĀHĪM', MB_CASE_TITLE, >>> 'UTF-8')); => string(11) "ʾibrāhīm" // <-- NOT GOOD: Lowercased 'I' due to preceding ʾ >>> var_dump(mb_convert_case('\'ibrāhīm', MB_CASE_TITLE, >>> 'UTF-8')); => string(10) "'ibrāhīm" // <-- NOT GOOD: Lowercased 'I' due to preceding apostrophe >>> var_dump(mb_convert_case('`ibrāhīm', MB_CASE_TITLE, >>> 'UTF-8')); => string(10) "`ibrāhīm" // <-- NOT GOOD: Lowercased 'I' due to preceding backtick >>> var_dump(mb_convert_case('"ibrāhīm', MB_CASE_TITLE, >>> 'UTF-8')); => string(10) ""ibrāhīm" // <-- Wrongly lowercased 'I' due to preceding quote ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79617&edit=1

« previous php.bugs (#227119) next »