Windows 中的语言环境列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5152866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:18:16  来源:igfitidea点击:

List of locales in Windows

cwindowslocalizationlocalesetlocale

提问by aib

On *nix systems you can do locale -ato get a list of available locales.

在 *nix 系统上,您可以locale -a获取可用语言环境的列表。

What is the equivalent command (or action) in Windows?

Windows 中的等效命令(或操作)是什么?

I've seen lists on the Internet, but most of them are of just locale labels and not actual locale names. Plus, not all systems are guaranteed to have all of them installed, right?

我在 Internet 上看到过列表,但其中大多数只是区域设置标签,而不是实际的区域设置名称。另外,并非所有系统都保证安装所有这些,对吗?

Note that my definition of "locale" here is "locale string", i.e. a second parameter to C's setlocale()which will result in a non-NULL return value.

请注意,我在这里对“语言环境”的定义是“语言环境字符串”,即 C 的第二个参数setlocale()将导致非 NULL 返回值。

Programmatic answers are also fine, I'm just tired of brute force guessing Windows locale names.

编程答案也很好,我只是厌倦了蛮力猜测 Windows 语言环境名称。

回答by Eric Pi

Initially, I couldn't find a C/Win32 API to get the information. (See later edit.) However, it looks like the .NET class System.Globalization.CultureInfocould provide the information you need. In particular, see CultureInfo.GetCultures(). This page seems to have a complete exampleof what you are looking for.

最初,我找不到 C/Win32 API 来获取信息。(请参阅稍后的编辑。)但是,看起来 .NET 类System.Globalization.CultureInfo可以提供您需要的信息。特别是,请参阅 CultureInfo.GetCultures()。此页面似乎有您正在寻找的完整示例

EDIT: If you prefer a C/Win32 API, see EnumSystemLocales() function.

编辑:如果您更喜欢 C/Win32 API,请参阅EnumSystemLocales() 函数。

EDIT 2: This exampleshows how to convert an LCID (which you get from EnumSystemLocales()) into a string useable by setlocale().

编辑 2:此示例显示如何将 LCID(您从 EnumSystemLocales() 获得)转换为 setlocale() 可用的字符串。

回答by aib

This pageseems to contain links to lists of language and country/region that the WIN32 setlocalerecognizes. However:

此页面似乎包含指向 WIN32 setlocale识别的语言和国家/地区列表的链接。然而:

The set of available languages, country/region codes, and code pages includes all those supported by the Win32 NLS API except code pages that require more than two bytes per character, such as UTF-7 and UTF-8. If you provide a code page like UTF-7 or UTF-8, setlocale will fail, returning NULL.

可用语言、国家/地区代码和代码页集包括 Win32 NLS API 支持的所有语言,但每个字符需要超过两个字节的代码页(例如 UTF-7 和 UTF-8)除外。如果您提供像 UTF-7 或 UTF-8 这样的代码页,setlocale 将失败,返回 NULL。

fail.

失败。