Setting locales (thread and invariant)

Two questions coming from the .NET World.

I understand that there is no way in Swift to change the thread's current locale (in .NET there is a way to change the thread's current "culture") and that only the device's current locale can be changed. Apparently, the device's current locale may not be changed programmatically. Is that right? If so, how will Swift running on a server handle requests from various clients whose locales may be different?

Is there such a concept as an "invariant" locale (to avoid notably surprizes with a Turkish device for instance). An invariant locale which could be used, for instance, with

String.range(of: pattern, options:.regularExpression, locale: locale)

?

(If there is no equivalent concept, I suppose one could use the English US locale... Although on .NET, invariant locale and US locale don't behave to same way when using toUpper() for µ U+00B5 and ı U+0131...)

Usually objects that make use of a Locale to do their computations accept injecting one, which by default will be the machine's.

So yes, you can specify "invariant" locales

Is there such a concept as an "invariant" locale

I believe the droid you’re looking for here is the en_US_POSIX locale.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

Terms of Service

Privacy Policy

Cookie Policy