>What you are asking seems could be done by a simple C wrapper around the C++ Locale
Yes! You’re proposing a simple C wrapper around LocaleBuilder, and I’m advocating for also adding a C wrapper around Locale.
Frank Yung-Fong Tang July 13, 2023 at 6:18 PM
What you are asking seems could be done by a simple C wrapper around the C++ Locale
Rich Gillam July 13, 2023 at 6:04 PM
To get the language code out of a locale ID in C right now involves doing something like this:
That’s a lot of boilerplate you have to write to do something simple, and it gets really onerous if you’re doing any kind of complicated transform from one locale ID to another locale ID, where you have to do this kind of thing for multiple fields of the ID.
What I want is something more like this:
It doesn’t seem a lot better when you’re only working with the one field, but if you’re having to extract several fields or values for the same locale ID, a lot of the overhead goes away.
If we’re going to go to the trouble of having a LocaleBuilder to make constructing locale IDs easier, either it should have getters to make extracting individual fields from locale IDs easier too, or we should have a C counterpart to the Locale object in C++ and Java that lets you do that.
This bug is filed to track the issue Rich mentioned about the need for an easier to use C API for getting locale.
I believe one issue Rich mentioned is the current get API always require the caller to supply a buffer and very complicate to use.