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

Fix localized_comparator for macOS #40100

Merged
merged 2 commits into from
May 3, 2020
Merged

Fix localized_comparator for macOS #40100

merged 2 commits into from
May 3, 2020

Conversation

akirashirosawa
Copy link
Contributor

Summary

SUMMARY: None

Purpose of change

As I wrote here Localized sorting #39873 not working for macOS:

for Russian on macOS it doesn't work at all :(
ru
As you can see, words starting with а are interrupted by words starting with other letters.

for German on macOS too, it (not?) works.
de

I don't know German, but Kajak sorts before Käfer, so it works only for Latin characters, not for German special ones.

Describe the solution

As I suggest here, for macOS use CFStringCompare instead std::locale compare.

Describe alternatives you've considered

Somehow make std::locale compare to work correctly on macOS.

Testing

Results for Russian:
ru

All is right order.

Results for German:
de
Käfer correctly sorts before Kajak and it's all i know about German :) (from example here #39873)

Additional context

More discussion here #40041

@ZhilkinSerg ZhilkinSerg added Info / User Interface Game - player communication, menus, etc. OS: macOS Issues related to macOS / OSX operating system labels May 3, 2020
@ZhilkinSerg ZhilkinSerg merged commit 964fe80 into CleverRaven:master May 3, 2020
@jbytheway
Copy link
Contributor

I think this could leak memory in the case where the CFString doesn't reuse the existing buffer. Based on the docs I think you should be calling CFRelease on the two created strings. But I'm not an OS X programmer, so I'm not totally sure.

@akirashirosawa akirashirosawa deleted the CFStringCompare-instead-std-locate-for-MacOS branch May 4, 2020 08:29
@akirashirosawa
Copy link
Contributor Author

@jbytheway Thank you for your comment. I read the docks and fixed a memory leak here #40131.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Info / User Interface Game - player communication, menus, etc. OS: macOS Issues related to macOS / OSX operating system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants