C++ Win32 API equivalent of CultureInfo.TwoLetterISOLanguageName

家住魔仙堡 提交于 2019-12-01 13:03:28

Thanks to Trevor for directing me toward this answer in an earlier reply.

Call GetLocaleInfo with the LOCALE_SISO639LANGNAME parameter.

See the GetLocaleInfo function. There are 2 LCType values you may be interested in: LOCALE_SABBREVCTRYNAME, and LOCALE_SABBREVLANGNAME. I did a quick test on Windows 7, and both returned 3 character strings, even though ISO 3166 uses 2 characters. The LOCALE_SABBREVLANGNAME documentation states it starts out with the 2 character ISO 3166 code and adds a third character for the sublanguage.

This is one area where Win API has evolved a lot since XP. I don't think you're going to find a function to do it that's available all the way back to XP. I believe the .NET framework stuff has its own built-in tables (at least for pre-Vista versions). GetUserDefaultLocaleName isn't even available on XP, and that doesn't do exactly what you want, and even if it did, it probably wouldn't be as complete on XP as it is on newer versions.

You might need to include your own table.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!