-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Perform localized comparison on Windows via wstring #40062
Merged
ZhilkinSerg
merged 3 commits into
CleverRaven:master
from
jbytheway:comparison_via_wstring
May 6, 2020
Merged
Perform localized comparison on Windows via wstring #40062
ZhilkinSerg
merged 3 commits into
CleverRaven:master
from
jbytheway:comparison_via_wstring
May 6, 2020
Conversation
This file contains 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
This was referenced May 3, 2020
jbytheway
force-pushed
the
comparison_via_wstring
branch
from
May 4, 2020 01:51
8dc5697
to
21afd0b
Compare
jbytheway
changed the title
Perform localized comparison via wstring
Perform localized comparison on Windows via wstring
May 4, 2020
jbytheway
force-pushed
the
comparison_via_wstring
branch
from
May 4, 2020 01:56
21afd0b
to
9f1565b
Compare
In light of the discussion in #40041 I've updated this PR to apply to Windows only. That looks like it ought to give us the best results there. So I'm marking this one ready for review. |
ZhilkinSerg
added
[C++]
Changes (can be) made in C++. Previously named `Code`
Info / User Interface
Game - player communication, menus, etc.
Translation
I18n
labels
May 4, 2020
jbytheway
force-pushed
the
comparison_via_wstring
branch
2 times, most recently
from
May 4, 2020 13:45
b058dd1
to
5352ff1
Compare
jbytheway
force-pushed
the
comparison_via_wstring
branch
from
May 5, 2020 12:55
5352ff1
to
12246fb
Compare
Added some tests to this PR. |
jbytheway
force-pushed
the
comparison_via_wstring
branch
from
May 5, 2020 15:46
12246fb
to
8149a36
Compare
On Windows the existing solution for localized comparison seems to do the wrong thing, but evidence suggests that comparison of wstring should work. Convert the strings before comparison on Windows. At the same time, do the reverse conversion on MacOS (this won't actually be used anywhere in the current code, but it seemse a good idea to implement it while we had the experimental data to suggest it was necessary. See CleverRaven#40041 for more discussion.
jbytheway
force-pushed
the
comparison_via_wstring
branch
from
May 5, 2020 16:29
8149a36
to
bd416b5
Compare
It works, case-insensitive. Thanks! |
This was referenced May 10, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[C++]
Changes (can be) made in C++. Previously named `Code`
Info / User Interface
Game - player communication, menus, etc.
OS: Windows
Issues related to Windows operating system
Translation
I18n
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.
Summary
SUMMARY: None
Purpose of change
On OS X and Windows the existing solution for localized comparison seems to be struggling.
@akirashirosawa found a workaround for OS X. This is intended to be a workaround for Windows. It's necessary because on Windows the locale cannot be assumed to be UTF-8 (indeed, it almost certainly isn't).
Describe the solution
Perform the comparison on
std::wstring
rather than string, which should sidestep any character encoding issues.Describe alternatives you've considered
We could do a similar trick with
std::u32string
, but I suspect that would be poorly supported on Windows.Testing
I can't test, but @ScampsAdams experiment here suggest that this should work.