-
Notifications
You must be signed in to change notification settings - Fork 5k
CultureNotFoundException
thrown when a keyboard with language tag und
is activated
#98543
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
Comments
Tagging subscribers to this area: @dotnet/area-system-globalization Issue DetailsDescriptionIf a user installs and activates an input method with the custom locale Reproduction Steps
Expected behaviorThe language should be selected and the app should not crash. Actual behaviorThe application crashes with the exception Call stack from a crash dump given me by a user experiencing this problem:
Regression?Unclear, although it appears that 4.x was working okay when I attempted a repro there. Known WorkaroundsDon't use the Configuration
Other informationIt appears that this is related to the use of the ICU API
ICU bug reports:
Keyman bug report -- original report: Other issues that may be related:
|
I think there is some confusion here. The thrown exception is not because .NET couldn't handle the name This doesn't mean .NET will succeed creating a culture with the name |
@tarekgh that was my initial assumption too (see #37789 which was precisely that). However, when I debugged my sample application, I found that .NET is translating from the transient locale 0x2000 correctly to get und-Latn, which it then passes in to ICU. To prove this, I added another transient locale, this time picking tpi-PG (Tok Pisin, Papua New Guinea), which was assigned LCID 0x2400:
Selecting and using tpi-PG never caused the exception, whereas selecting und-Latn consistently did (note: if the text field was already focused when I switched languages, then the first keystroke would throw). I debugged
GlobalizationMode flags are all default and recommended settings:
Rough sequence of events:
So I think my initial analysis is correct. Side note: as an experiment, in the debugger, I overrode the |
@mcdurdin thanks for your investigation and analysis. I agree with you now 😄. I didn't know that WPF was getting a transient LCID 0x2000 and passing it to the .NET. This explains why this worked on the .NET Framework too. By the way, you can enable Using NLS instead of ICU which should make it work without hacking values under the debugger. |
Thanks-- I will document the globalization nls flag as a workaround for our users as well. It was useful to verify the root cause in the debugger though without other potential side effects 😀 |
If you want bcp47 you should definitely be using uloc_toLanguageTag. We wrote the other apis long before bcp47 existed, now they should have warnings on them. |
There is two issues here, one is |
Uh oh!
There was an error while loading. Please reload this page.
Description
If a user installs and activates an input method with the custom locale
und-Latn
, a .NET application will instantly crash withCultureNotFoundException
thrown ultimately bySystem.Globalization.CultureData.GetCultureData(Int32, Boolean)
.Reproduction Steps
und-Latn
using e.g. PowerShell:Expected behavior
The language should be selected and the app should not crash.
Actual behavior
The application crashes with the exception
CultureNotFoundException
Call stack from a crash dump given me by a user experiencing this problem:
Regression?
Unclear, although it appears that 4.x was working okay when I attempted a repro there.
Known Workarounds
Don't use the
und
language tag.Configuration
Other information
It appears that this is related to the use of the ICU API
uloc_canonicalize()
in pal_locale.c:GetLocale(), which treatsund
as a default or "no language" and strips it off, returning_Latn
when passedund-Latn
.FixupLocaleName()
in pal_locale.c will convert_
back to-
to bring the tag back into the format expected by .NET framework. However, the edge case ofund
being removed entirely is not handled. It may be possible to replaceFixupLocaleName()
with a call touloc_toLanguageTag()
:uloc_toLanguageTag("_Latn")
yieldsund-Latn
(but I have not verified that this is an exact match for requirements).ICU bug reports:
uloc_canonicalize()
.Keyman bug report -- original report:
Other issues that may be related:
und
)Many thanks to @srl295 for his assistance in tracing this.
The text was updated successfully, but these errors were encountered: