关于windows下Postgresql数据库的注册表键值locale

本文探讨了Linux和Windows系统下的locale概念,特别是在中文Windows环境下locale的设置与表现。通过安装PostgreSQL的过程,分析了注册表中locale的配置,及其与OracleDatabase中NLS_LANG的相似之处。详细解析了locale的构成,包括语言、国家和地区代码,以及代码页的含义和作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

说到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代码页是不同的。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值