Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MB_CASE_FOLD doesn't handle ẞ character properly #173

Closed
colinodell opened this issue May 1, 2019 · 2 comments · Fixed by #427
Closed

MB_CASE_FOLD doesn't handle ẞ character properly #173

colinodell opened this issue May 1, 2019 · 2 comments · Fixed by #427

Comments

@colinodell
Copy link

Summary

It seems that this polyfill incorrectly case-folds the character to ß instead of ss.

Details

Running this code on PHP 7.3 with mbstring installed:

echo mb_convert_case('', MB_CASE_FOLD);

Will produce this output: ss

However, when I run that same input through this polyfill (master branch):

echo \Symfony\Polyfill\Mbstring\Mbstring::mb_convert_case('', \Symfony\Polyfill\Mbstring\Mbstring::MB_CASE_FOLD);

I instead get ß. This does not match mbstring's behavior on PHP 7.3.

@colinodell
Copy link
Author

It looks like this occurs with both U+1E9E LATIN CAPITAL LETTER SHARP S and U+00DF LATIN SMALL LETTER SHARP S. Both of these should return ss when case-folded.

@nicolas-grekas
Copy link
Member

PHP 7.3 uses full case folding.
This is implemented in tchwork/utf8, so we could borrow the map from there:
https://github.com/tchwork/utf8/blob/30ec6451aec7d2536f0af8fe535f70c764f2c47a/src/Patchwork/Utf8.php#L168-L170

Up for a PR?

symfony-splitter pushed a commit to symfony/polyfill-mbstring that referenced this issue Jul 29, 2023
This PR was merged into the 1.28-dev branch.

Discussion
----------

Add case folding map

Fixes symfony/polyfill#173

`@nicolas`-grekas, I've indeed borrowed the map you pointed at in the issue. Thanks for this!

Commits
-------

3d151ba Add case folding map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants