I have string data representing locales, like "fr" or "en". I need to convert it to the appropriate LCID values, like 0x80c or 0x409. Is there a function or macro to do so?
I'm using C++ on Windows 7.
Those are LCID values, not sure what LID means. You can get them out of GetLocaleInfoEx(), available in Vista and up. You need to pass a locale name like "en-US", necessary to nail down the language locale. For example:
#include "stdafx.h"
#include <windows.h>
#include <assert.h>
int _tmain(int argc, _TCHAR* argv[])
{
LCID lcid = 0;
BOOL ok = GetLocaleInfoEx(L"en-US", LOCALE_RETURN_NUMBER | LOCALE_ILANGUAGE, (LPWSTR)&lcid, sizeof(lcid));
assert(ok);
wprintf(L"LCID = %04x\n", lcid);
return 0;
}
Output: LCID = 0409
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With