Swift numeric default string interpolation locale?

Does the default Swift string interpolation (example: "Orange count: (76341)") always output in the "en_US_POSIX" locale (or equivalent)? Or does it depend on the user's locale?

For example, using a number formatter with a locale of "fa_IR" produces: "۷۶۳۴۱" (for 76341).

I'm curious to know if there's any way a user's locale or language settings can affect the "default" string interpolation, since we use that often to set values in headers to web servers, and those have to be in English numbers.

Can I safely use default string interpolation for that or should I use an explicit number formatter (with "en_US_POSIX") to be sure?

Hi, string interpolation is not localized, unless it’s initialized within String(localized:) or SwiftUI views like Text().

When it’s localized, numbers use the user’s preferred locale, or a specific locale you pass via String(localized:locale:).

// With preferred locale ar_SA:

print("Test \(123)")                    // Prints `Test 123`.
print(String(localized: "Test \(123)")) // Prints `Test ١٢٣`.

Thank you very much, that answered my question and then some!

Swift numeric default string interpolation locale?
 
 
Q