5

Postgres 9.2 on Windows 7, I'm trying to create English_United States.1252 custom collation:

user=# create database test template template0 ENCODING = 'utf8' LC_COLLATE = 'English_United States.1252' LC_CTYPE = 'English_United States.1252';
CREATE DATABASE
user=# \c test
test=# create collation english from "English_United States.1252";
ERROR:  collation "English_United States.1252" for encoding "UTF8" does not exist

And as you see, the following error is displayed: ERROR: collation "English_United States.1252" for encoding "UTF8" does not exist

What's the proper way to create English United States collation on Windows for utf8 db encoding?

JJJ
  • 32,902
  • 20
  • 89
  • 102
Michal
  • 2,078
  • 19
  • 29
  • 3
    My guess would be that the "1252` in the collation name refers to "Windows codepage 1252", which is a variant of ISO8859-1, an 8-bit fixed encoding. So adding that collation with a UTF-8 (Unicode) encoding would make no sense. – IMSoP Nov 08 '13 at 16:47
  • 4
    This statement appears to work for me (pg 9.2.4 on WinXP). Also [the manual](http://www.postgresql.org/docs/current/static/multibyte.html) says: _On Windows, however, UTF-8 encoding can be used with any locale_, which refutes the theory of UTF-8 incompatibility with the *.1252 locale. – Daniel Vérité Nov 08 '13 at 19:08
  • @Daniel Vérité I'm using Postgres 9.2.2 on Windows 7 – Michal Nov 12 '13 at 09:53
  • 2
    If windows had the equivalent of `locale -a` you could check if this `English_United States` locale is installed on your system. There's an [open question](http://stackoverflow.com/questions/5152866) about this on S.O., it doesn't seem simple unless you can code a Win32 API call. – Daniel Vérité Nov 12 '13 at 14:59
  • The use of the keyword FROM means that command is not trying to create a new collation, it's trying to copy one. To create a collation you may use: CREATE COLLATION "English_United States.1252" (LC_COLLATE='English_United States.1252', LC_CTYPE='English_United States.1252'); Unfortunately while this is creatable in Windows it doesn't use UTF-8. – jchevali Jan 23 '19 at 22:04
  • (cont'd) Actually, it probably does use UTF-8, since at least in my system, an inspection of the record created in pg_collation for the new collation reveals collencoding = 6, while pg_encoding_to_char(6) returns 'UTF8'. I shall therefore promote this comment to an answer. – jchevali Jan 23 '19 at 22:52

0 Answers0