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

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

LC_COLLATE and LC_CTYPE suport for utf-8 in postgreSQL

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:Collat​​ehttp://www.postgresql.org/docs/9.1/static/collat​​ion.html。这让我很困惑。

They said, utf-8support depends on OS capability, and its deferent between every LC_COLLATEand LC_CTYPEoptions.

他们说,utf-8支持取决于操作系统的能力,它的每一个之间输精管LC_COLLATELC_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_COLLATEand LC_CTYPEfor creating database that support utf-8in PostgreSQL 9?

我必须为选择的值LC_COLLATE,并LC_CTYPE为支持创建数据库utf-8PostgreSQL 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 (Posixis as same as Cand 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 Clocale for that platform. I don't know why installer has POSIX option (I guess it's rather a bug):

Windows 平台不兼容 POSIX,因此您应该使用C该平台的语言环境。我不知道为什么安装程序有 POSIX 选项(我猜这是一个错误):

enter image description here

在此处输入图片说明

To create new cluster without locale you can simply use --no-localeswitch e.g.:

要创建没有语言环境的新集群,您可以简单地使用--no-localeswitch 例如:

initdb --no-locale -E UTF-8 C:\pgdata