Repository navigation
[Mbstring] Use titlecase mappings for MB_CASE_TITLE - #720
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Member
|
Thank you @wleeaf. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mb_convert_case($s, MB_CASE_TITLE)uppercases the first letter of each word instead of titlecasing it. The two differ for digraphs, Georgian, Greek letters with ypogegrammeni, and the ligatures andßof SpecialCasing.txt:Georgian text is the most visible case. Mkhedruli letters titlecase to themselves, so the polyfill turns the first letter of every Georgian word into Mtavruli.
mb_ucfirst()goes through the same code when mbstring is missing.Compiler::unicodeMaps()now also writes atitleCase.phpmap. It holds the entries whose titlecase mapping differs from the uppercase one: field 14 of UnicodeData.txt and the title column of the unconditional SpecialCasing.txt rules.title_case()uses it before falling back to the uppercase map. I generated the map from the Unicode 13.0.0 files, the version the currentupperCase.phpandlowerCase.phpcome from (regenerating those two from 13.0.0 gives identical files).update-unidata.phpmoves the new file next to them.The existing title-case assertion in
testStrCase()sat behindif (\PCRE_VERSION >= '8.10'). That compares strings, so it is false for every PCRE2 version ("10.42 ..." < "8.10") and the assertion never ran on PHP >= 7.3. I removed the guard, since all supported PHP versions ship a PCRE that supports the regexp, and added an assertion for the cases above. The new assertion fails without the change.On 20k random strings, the polyfill's
MB_CASE_TITLEresult differs from PHP 8.5's in 13947 cases before this change and 6616 after, and no string that matched before differs now. The remaining differences are final sigma and word boundaries after case-ignorable characters such as·, which are separate issues../phpunit tests/Mbstringpasses.