LC_COLLATE 和 LC_CTYPE 支持 postgreSQL 中的 utf-8
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6579621/
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
LC_COLLATE and LC_CTYPE suport for utf-8 in postgreSQL
提问by Ahmad
From this link http://wiki.postgresql.org/wiki/Todo:Collateand http://www.postgresql.org/docs/9.1/static/collation.html. it's make me confused.
从这个链接http://wiki.postgresql.org/wiki/Todo:Collate和http://www.postgresql.org/docs/9.1/static/collation.html。这让我很困惑。
They said, utf-8
support depends on OS capability, and its deferent between every LC_COLLATE
and LC_CTYPE
options.
他们说,utf-8
支持取决于操作系统的能力,它的每一个之间输精管LC_COLLATE
和LC_CTYPE
选项。
When I create database using pdAdmin III
, there is 3 option, C, Posix and English_United States.1252
. What's the different between C, Posix and English_United States.1252
?
当我使用创建数据库时pdAdmin III
,有 3 个选项,C, Posix and English_United States.1252
. 之间有C, Posix and English_United States.1252
什么不同?
I want work with all languages supported, that is unicode utf-8
, which doesn't seem to be an option.
我希望使用支持的所有语言,即unicode utf-8
,这似乎不是一种选择。
What I must chose for the values of LC_COLLATE
and LC_CTYPE
for creating database that support utf-8
in PostgreSQL 9
?
我必须为选择的值LC_COLLATE
,并LC_CTYPE
为支持创建数据库utf-8
的PostgreSQL 9
?
采纳答案by Grzegorz Szpetkowski
As documentation, 22.2. Character Set Supportsays:
作为文档,22.2。字符集支持说:
An important restriction, however, is that each database's character set must be compatible with the database's LC_CTYPE (character classification) and LC_COLLATE (string sort order) locale settings. For C or POSIX locale, any character set is allowed, but for other locales there is only one character set that will work correctly. (On Windows, however, UTF-8 encoding can be used with any locale.)
但是,一个重要的限制是每个数据库的字符集必须与数据库的 LC_CTYPE(字符分类)和 LC_COLLATE(字符串排序顺序)区域设置兼容。对于 C 或 POSIX 语言环境,允许使用任何字符集,但对于其他语言环境,只有一种字符集可以正常工作。(但是,在 Windows 上,UTF-8 编码可用于任何语言环境。)
I see that probably you have PostgreSQL under Windows host (English_United States.1252 locale
), so you can use whatever of these (Posix
is as same as C
and means "no locale"), read 22.1. Locale Support:
我看到您可能在 Windows 主机 ( English_United States.1252 locale
)下安装了 PostgreSQL ,因此您可以使用其中任何一个(与“无语言环境”Posix
相同C
并表示“无语言环境”),请阅读22.1。语言环境支持:
Locale support refers to an application respecting cultural preferences regarding alphabets, sorting, number formatting, etc.
If you want the system to behave as if it had no locale support, use the special locale C or POSIX.
语言环境支持是指尊重有关字母、排序、数字格式等文化偏好的应用程序。
如果您希望系统表现得好像它没有语言环境支持,请使用特殊的语言环境 C 或 POSIX。
EDIT:
编辑:
Windows platform isn't POSIX compliant, so you should use C
locale for that platform. I don't know why installer has POSIX option (I guess it's rather a bug):
Windows 平台不兼容 POSIX,因此您应该使用C
该平台的语言环境。我不知道为什么安装程序有 POSIX 选项(我猜这是一个错误):
To create new cluster without locale you can simply use --no-locale
switch e.g.:
要创建没有语言环境的新集群,您可以简单地使用--no-locale
switch 例如:
initdb --no-locale -E UTF-8 C:\pgdata