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

.NET 9 iOS / HybridGlobalization: currency symbols / currency names not available #108958

Open
tipa opened this issue Oct 17, 2024 · 8 comments
Open
Assignees
Milestone

Comments

@tipa
Copy link

tipa commented Oct 17, 2024

Description

With .NET 9, the current currency symbol / currency code are not available any more / replaced by the generic currency symbol

Reproduction Steps

  • dotnet new ios
  • use code below

Expected behavior

var a = RegionInfo.CurrentRegion.CurrencyEnglishName; // USD
var b = RegionInfo.CurrentRegion.ISOCurrencySymbol; // USD
var c = RegionInfo.CurrentRegion.CurrencyNativeName; // USD
var d = RegionInfo.CurrentRegion.CurrencySymbol; // $
var e = CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol; // $

Actual behavior

var a = RegionInfo.CurrentRegion.CurrencyEnglishName; // empty string
var b = RegionInfo.CurrentRegion.ISOCurrencySymbol; // empty string
var c = RegionInfo.CurrentRegion.CurrencyNativeName; // empty string
var d = RegionInfo.CurrentRegion.CurrencySymbol; // ¤
var e = CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol; // ¤

Regression?

Yes, it worked in .NET 8, even with HybridGlobalization=true

Known Workarounds

I can just use the iOS methods NSLocale.CurrentLocale.CurrencySymbol or NSLocale.CurrentLocale.CurrencyCode

Configuration

.NET 9 RC2
iPhone SE 2 (system language German)

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Oct 17, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-globalization
See info in area-owners.md if you want to be subscribed.

@tarekgh tarekgh added the os-ios Apple iOS label Oct 17, 2024
Copy link
Contributor

Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @ivanpovazan, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

@tarekgh
Copy link
Member

tarekgh commented Oct 17, 2024

cc @matouskozak

@matouskozak matouskozak removed the untriaged New issue has not been triaged by the area owner label Oct 17, 2024
@matouskozak matouskozak added this to the 10.0.0 milestone Oct 17, 2024
@matouskozak
Copy link
Member

matouskozak commented Oct 18, 2024

@tipa what culture is your application using?

I see the correct output after setting the culture to en-US.

@tipa
Copy link
Author

tipa commented Oct 18, 2024

@matouskozak I see these results:

CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol  -> ¤
CultureInfo.CurrentCulture.Name  -> "en"
new CultureInfo("en-US").NumberFormat.CurrencySymbol -> $
new CultureInfo("de-DE").NumberFormat.CurrencySymbol -> €
new CultureInfo("en").NumberFormat.CurrencySymbol -> ¤

Is this the expected behaviour?

@matouskozak
Copy link
Member

I think en is a "neutral" culture code. You can set the specific culture (en-US) using https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.defaultthreadcurrentculture?view=net-9.0 and it should work as expected.

@tipa
Copy link
Author

tipa commented Oct 18, 2024

I don't (want to) set the current culture myself - and I don't know the users culture (region). My use-case was to show a default currency symbol in my app, that the user could edit. Previously (.NET 8, even with HybridGlobalization=true) my code returned a $ for US users, probably because CultureInfo.CurrentCulture did not return a neutral culture. If this was an expected change, then that's ok and we can close this issue :) I have my workaround with NSLocale.CurrentLocale.CurrencySymbol anyways

@matouskozak
Copy link
Member

matouskozak commented Oct 18, 2024

I don't (want to) set the current culture myself - and I don't know the users culture (region). My use-case was to show a default currency symbol in my app, that the user could edit. Previously (.NET 8, even with HybridGlobalization=true) my code returned a $ for US users, probably because CultureInfo.CurrentCulture did not return a neutral culture. If this was an expected change, then that's ok and we can close this issue :) I have my workaround with NSLocale.CurrentLocale.CurrencySymbol anyways

I think it is not expected change, and we should investigate.

@matouskozak matouskozak self-assigned this Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants