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

From: Date: Thu, 21 May 2020 18:09:46 +0000
Subject: Bug #79617 [Opn]: 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-227114@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: girgias@php.net Reported by: dedienaar+phpnet at gmail dot com Summary: mb_convert_case() with MB_CASE_TITLE unexpected behavior for second characters Status: Open Type: Bug Package: *Unicode Issues Operating System: Ubuntu 18.04.4 LTS PHP Version: 7.2.31 -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: 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) Previous Comments: ------------------------------------------------------------------------ [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 (#227114) next »