How to parse country code from RFC 5646 locale string?

16 Views Asked by At

The GetUserDefaultLocaleName Win32 API returns a locale name string based on RFC 5646. How can I retrieve the country code from this string?

The format doesn't have an obvious way to do this, because it has a variable number of entries. For example, Latin-script Uzbek in Uzbekistan is uz-Latn-UZ. Given that entries can also appear after the country code, how would I know which part is the country code?

0

There are 0 best solutions below