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

[iOS/HybridGlobalization] No space between time and AM/PM designator #102250

Closed
tipa opened this issue May 15, 2024 · 9 comments · Fixed by #103226
Closed

[iOS/HybridGlobalization] No space between time and AM/PM designator #102250

tipa opened this issue May 15, 2024 · 9 comments · Fixed by #103226
Assignees
Milestone

Comments

@tipa
Copy link

tipa commented May 15, 2024

Description

When using hybrid globalization on iOS and using the short time specifier, there is no space in front of the "AM" or "PM".

Reproduction Steps

var date = DateTime.Today + TimeSpan.FromHours(15) + TimeSpan.FromMinutes(15);
var culture = new CultureInfo("en-US");
System.Diagnostics.Debug.WriteLine(date.ToString("t", culture));

Expected behavior

3:15 PM

Actual behavior

3:15PM

Regression?

No response

Known Workarounds

No response

Configuration

macos 14.2.8053/8.0.100 SDK 8.0.200
ios 17.2.8053/8.0.100 SDK 8.0.200

iOS 17.2

Other information

The same problem happens when using the long time format specified ("T").
The space is present as expected when not using hybrid globalization

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label May 15, 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.

@ilonatommy
Copy link
Member

@mkhamoyan, in

const char* GlobalizationNative_GetLocaleTimeFormatNative(const char* localeName, int shortFormat)
we are using methods that according to the documentation:
https://developer.apple.com/documentation/foundation/nsdateformatterstyle/nsdateformattershortstyle
https://developer.apple.com/documentation/foundation/nsdateformatterstyle/nsdateformattermediumstyle
should return formats with the space. Is it possible that we format it on the fly? Or might it be a behavioral change between iOS's ICU version?

@ilonatommy ilonatommy removed their assignment May 17, 2024
@mkhamoyan
Copy link
Contributor

mkhamoyan commented May 17, 2024

We see bahavioural change as there was a fix in ICU flow ( see #83589) and now

private static string ConvertIcuTimeFormatString(ReadOnlySpan<char> icuFormatString)
and
private static string ConvertNativeTimeFormatString(string nativeFormatString)
have different implementations.
I will open a PR to use same function for both flows.

@vitek-karas
Copy link
Member

@matouskozak fyi

@mkhamoyan
Copy link
Contributor

mkhamoyan commented Jun 5, 2024

I am not able to reproduce this issue in the .NET 8 repo (works as expected on .Net 9 also).
@tipa Could you please specify whether you created the project using dotnet new maui or dotnet new ios?

@tipa
Copy link
Author

tipa commented Jun 5, 2024

I can still reproduce this with .NET 8. I am using dotnet new ios.
It only happens when using <HybridGlobalization>true</HybridGlobalization>

@mkhamoyan
Copy link
Contributor

Thanks! I can reproduce with dotnet new ios

@kalin-todorov
Copy link

kalin-todorov commented Jun 6, 2024

I can still reproduce this with .NET 8. I am using dotnet new ios. It only happens when using <HybridGlobalization>true</HybridGlobalization>

I'm reproducing the issue in .Net 9 project without setting HybridGlobalization. The project was created with dotnet new ios and I'm using the latest preview 4.

image

@mkhamoyan
Copy link
Contributor

In .NET 9 HybridGlobalization is the default and only mode.
I was previously unable to reproduce the issue because I was targeting an iOS device running version 16.7.8, which uses an older ICU version.

It appears that recent ICU versions have introduced a change where regular spaces are replaced with non-breaking spaces (NBSP / \u00A0) or narrow non-breaking spaces (NNBSP / \u202F). For more details, see the related ICU change.

I will open a PR to handle these cases properly.

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