Open danielsafrigin opened 4 months ago
The following code will always result in "Locale Name: *".
That is the expected behavior as defined by the C++ standard: Basically any modified locale has the name "*"
is there an appropriate way to test for any locale we generate if it's valid?
It was a design decision (by the original author) that there is no such thing as an invalid locale. You can use Boost.Locale to generate a std::locale
for any name you want. Any "part" that doesn't "exist" is basically using the C locale. This is true for all of the library: Try as good as possible and gradually fall back to the C locale to provide "something reasonable"
Note that not constraining the input locale name to something that can be "fully supported" is useful to provide partial support for e.g. only formatting and/or translations.
I'm using Ubuntu with full boost installation with ICU. The following code will always result in "Locale Name: ". It doesn't matter if it's a valid locale like "en_US.UTF-8", or a not valid one like "super_random_text.UTF-8", name() always returns .
I can validate for a Turkish locale by testing functionality:
output:
is there an appropriate way to test for any locale we generate if it's valid?