Windows:从语言环境字符串获取LCID? [英] Windows: Get LCID from locale string?

查看:132
本文介绍了Windows:从语言环境字符串获取LCID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有表示语言环境的字符串数据,例如"fr"或"en".我需要将其转换为适当的LCID值,例如0x80c0x409.有功能或宏吗?

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?

我在Windows 7上使用C ++.

I'm using C++ on Windows 7.

推荐答案

这些是LCID值,不确定LID是什么意思.您可以从Vista和更高版本中提供的GetLocaleInfoEx()中获取它们.您需要传递一个诸如"en-US"之类的语言环境名称,这是确定语言语言环境所必需的.例如:

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;
}

输出:LCID = 0409

Output: LCID = 0409

这篇关于Windows:从语言环境字符串获取LCID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆