-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add globalization sample #4414
Add globalization sample #4414
Conversation
Here is good example for the collation: CompareInfo turkishCompare = new CultureInfo("tr-TR").CompareInfo;
Console.WriteLine(turkishCompare.Compare("i", "\u0130", CompareOptions.IgnoreCase)); // print 0 as "i" is equal to Turkish I "\u0130".
CompareInfo englishCompare = new CultureInfo("en-US").CompareInfo;
Console.WriteLine(englishCompare.Compare("i", "\u0130", CompareOptions.IgnoreCase)); // print -1 as "i" is not equal to Turkish I "\u0130" in non-Turkish cultures. |
I like the Turkish I example. While it's not exactly obscure, it is also a bit of a novelty. I wonder if there are other cases we should cover. For example, if you were building an e-commerce app in Westerrn Europe or US, can you get away with globalization invariant mode? If not, what's an obvious example for why not? |
For timezone specifically, we've had multiple issues in the main repository with people volume mounting If we're dealing with just timezone data, there's all sorts of fun timezones with relatively recent "fun" adjustments, or quite unusual offsets that are lesser known in the western world. |
I didn't know about the pattern to mount the directory. I can include that. Yes, I am familiar with local time being an anti-pattern. The current text makes it sound like we're encouraging it, which isn't the intent. I can update that. People appear to be doing this (from my research), which led me to want to include it. When the timezone file is mounted, what does it typically content? Is it the UTC value? Thanks for the feedback. Appreciated. |
Uh, no. docker run --rm -e TZ=$(cat /etc/timezone) mcr.microsoft.com/dotnet/aspnet:6.0-focal date We especially don't want people mounting |
@richlander please don't use the mounting options. The issue dotnet/runtime#60469 has detailed discussions about that. In short, Most Linux systems do file system symbolic/hard linking to the zone files. If you are mounting any TZ file to the container, it will interfere with that and will start producing inconsistent results for the time conversions and reporting zone names. As @Clockwork-Muse mentioned, please use |
Here is a good example: // Å LATIN CAPITAL LETTER A WITH RING ABOVE is equal to 'A' + '\u030A'
CompareInfo englishCompare = new CultureInfo("en-US").CompareInfo;
Console.WriteLine(englishCompare.Compare("\u00C5", "A\u030A")); |
@Clockwork-Muse Thanks for that it. It makes sense. In practice, what value would you expect in |
In my case it's |
... using NTP to interface with the host's time seems a bit much (you'd have to set it at a server), and NTP doesn't handle timezones anyways. ChatGPT is wong. If it was better, it would try to warn you away from setting timezone for the container in the first place. |
Just saw your comment now, but I removed that extra info. Good now? I very much appreciate the help! |
You might want to take a look at this other PR, too @Clockwork-Muse . It is dealing with some of the same concepts. |
I believe I have addressed all the feedback. |
Fixed merge conflict with other PR. |
Globalization invariant mode is a major part of our size optimization strategy, yet, we don't have much guidance on how to use it correctly. However, we do receive feedback about these topics. Also, we don't have great policies of when to install
icu
andtzdata
. This sample will hopefully help inform that.Related to #4413