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 calling NLS with Cultures has alternative sort names #61992

Conversation

tarekgh
Copy link
Member

@tarekgh tarekgh commented Nov 23, 2021

Fixes #61977

In .NET 6.0 and when running on Windows, we have switched to call NLS to get some properties which are not available with ICU. CultureInfo.TextInfo.ANSICodePage is a good example of that. When we are calling NLS in such cases we use the internal culture name stored in _sWindowsName. The problem here is when using cultures which have alternative sorts (e.g. es-ES_tradnl) such names will be stored as es_ES@collation=tradnl to be used when calling ICU too. If this name is used with NLS, the calls will fail. The fix here is to use the name that works with Windows which is stored in the field sRealName instead. On NLS mode, _sWindowsName is same as _sRealName so this change shouldn't affect this mode.

@ghost
Copy link

ghost commented Nov 23, 2021

Tagging subscribers to this area: @tarekgh, @safern
See info in area-owners.md if you want to be subscribed.

Issue Details

In .NET 6.0 and when running on Windows, we have switched to cl NLS to get some properties which are not available with ICU. CultureInfo.TextInfo.ANSICodePage is a good example of that. When we are calling NLS in such cases we use the internal culture name stored in _sWindowsName. The problem here is when using cultures which have alternative sorts (e.g. es-ES_tradnl) such names will be stored as es_ES@collation=tradnl to be used when calling ICU too. If this name is used with NLS, the calls will fail. The fix here is to use the name that works with Windows which is stored in the field sRealName instead. On NLS mode, _sWindowsName is same as _sRealName so this change shouldn't affect this mode.

Author: tarekgh
Assignees: -
Labels:

area-System.Globalization

Milestone: -

@tarekgh
Copy link
Member Author

tarekgh commented Nov 23, 2021

@safern could you please help reviewing this one?

@tarekgh tarekgh requested a review from safern November 23, 2021 23:15
@tarekgh tarekgh added this to the 7.0.0 milestone Nov 23, 2021
Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, makes sense!

@tarekgh
Copy link
Member Author

tarekgh commented Nov 24, 2021

I logged the issue for the unrelated CI failure.

@tarekgh tarekgh merged commit 5a3070c into dotnet:main Nov 24, 2021
@tarekgh tarekgh deleted the CallNlsWithNormalizedCollationNameForAlternativeSortsLocales branch November 24, 2021 18:35
@tarekgh
Copy link
Member Author

tarekgh commented Nov 29, 2021

/backport to release/6.0

@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1517839642

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ANSICodePage returns zero for Traditional_Spanish_CI_AS collation
2 participants