说到locale,其实linux下也有,使用命令locale -a可以查询出本linux操作系统已经安装的locale,使用locale -a -v 能获得更为详细的信息。
那windows下,中文版的windows,将locale翻译为"区域”,从控制面板中可以看到区域设置。locale的值是什么,有哪些值?
为了研究这个问题,我从www.postgresql.org下载了edb公司制作的postgresql 11.5 for windows的介质,安装完成之后,打开注册表(开始-运行,敲入命令regedit),定位到如下位置:
当然,这与我安装postgresql时的选择有关,如下是我当时的选择:
我理解上图注册表中的Locale,就类似于Oracle Database在windows注册表中的键:NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK(见下图)
关于Oracle Database的NLS_LANG,请见我的转帖文章:https://blog.youkuaiyun.com/msdnchina/article/details/100807470
但是在cmd窗口中,set locale=en-US 或者 set locale=English_Austrilia 之后,
D:\PostgreSQL\pg11.5\bin>psql -d postgres -U postgres -p 5901
用户 postgres 的口令: ---->>>这个提示还是中文的。。。
这是我比较奇怪的!先暂时记录一下。
当然,PostgreSQL中的Locale,有其他的环境变量也能达到类似的效果,比如设置提示信息的语言用 set lc_messages=C 或者set lc_messages=en_us
那么继续分析Locale=Chinese (Simplified)_China.936的构成,
显然,构成如下:语言_国家.代码页
代码页(CodePage)的定义如下:
An ordered set of characters of a specific script in which a numerical index (code-point
value) is associated with each character.
Code pages are a means of providing support for character sets and keyboard layouts used in different countries.
Devices such as the display and keyboard can be configured to use a specific code page and to switch from one code page (such as the United States) to another (such as Portugal) at the user's request.
上面对代码页(CodePage)解释来源于如下链接中的pdf文档
https://docs.microsoft.com/zh-cn/openspecs/windows_protocols/ms-ucoderef/4a045e08-fc29-4f22-baf4-16f38c2825fb
上面对代码页的解释,换成我的理解,就是字符的编码规则。
代码页的更多知识,请参见如下网址:
https://docs.microsoft.com/en-us/windows/win32/intl/code-pages
代码页936代表:ANSI/OEM Simplified Chinese (PRC,Singapore); Chinese Simplified (GB2312)
参考自:如下链接中的pdf文档(请搜索pdf文档中的936即可定位)
https://docs.microsoft.com/zh-cn/openspecs/windows_protocols/ms-ucoderef/4a045e08-fc29-4f22-baf4-16f38c2825fb
ANSI codepage
Windows codepages are also sometimes referred to as active codepages or system active
codepages. Windows always has one currently active Windows codepage. All ANSI Windows
functions use the currently active codepage.
The usual ANSI codepage ID for US English is codepage 1252.
Windows codepage 1252, the codepage commonly used for English and other Western European
languages, was based on an American National Standards Institute (ANSI) draft. That draft
eventually became ISO 8859-1, but Windows codepage 1252 was implemented before the
standard became final, and is not exactly the same as ISO 8859-1
OEM是命令提示符codepage,
额外注意:对于非中文、日文、韩文,ANSI codepage和OEM代码页是不同的。