jebusayah
jebusayah

Reputation: 25

How to get language name from language id in C++?

I have the language name "en-US" or "en", which maps to English. I want to convert it to its language code 0x0409.

Is there a built in windows API in C++ I can use to do this or do I have to implement it myself?

Edit: I made a mistake in my original question.

Upvotes: 0

Views: 1560

Answers (2)

Konrad Rudolph
Konrad Rudolph

Reputation: 545885

Use GetLocaleInfo with the LOCALE_SNAME locale information type:

int locale_id = 0x0409;
constexpr int max_locale_sname_len = 85;
TSTR[max_locale_sname_len] locale_iso_name;
int result = GetLocaleInfo(
    MAKELCID(locale_id),
    LOCALE_SNAME,
    locale_iso_name,
    max_locale_sname_len
);

Upvotes: 3

xander
xander

Reputation: 1765

There exists an GetLocaleInfo function, I think that is what you are looking for?

Upvotes: 0

Related Questions