Thread: create a database with encoding LATIN1

create a database with encoding LATIN1

From
Sébastien D'Errico
Date:

Hello everyone!

 

I read several old messages about encoding. I consult the documentation about initdb and the light bulb still does not “click” over my head.

 

I installed Postgres 8.4 on Windows 2008.

 

I am trying to create a database with encoding LATIN1. This is the result when I list all database:

 

[CONSOLE]

 

>psql -Upostgres –l

 

   Name    |    Owner    | Encoding  |      Collation      |        Ctype        |    Access privileges

-----------+-------------+-----------+---------------------+---------------------+--------------------------

postgres  | postgres    | UTF8      | English_Canada.1252 | English_Canada.1252 |

sderrico  | _postgresql | SQL_ASCII | English_Canada.1252 | English_Canada.1252 |

template0 | postgres    | UTF8      | English_Canada.1252 | English_Canada.1252 | =c/postgres : postgres=CTc/postgres

template1 | postgres    | UTF8      | English_Canada.1252 | English_Canada.1252 | postgres=CTc/postgres : _postgresql=CTc/postgres

test1     | postgres    | UTF8      | English_Canada.1252 | English_Canada.1252 |

 

[/CONSOLE]

 

This is the error message that I got when I tried to create the database:

 

[CONSOLE]

 

>create database test2 ENCODING='LATIN1';

 

ERROR:  encoding LATIN1 does not match locale English_Canada.1252

DETAIL:  The chosen LC_CTYPE setting requires encoding WIN1252.

 

[/CONSOLE]

 

So I tried to change the encoding:

 

[CONSOLE]

 

>initdb -E LATIN1 -d D:/data

 

initdb: encoding mismatch

The encoding you selected (LATIN1) and the encoding that the selected locale uses (WIN1252) do not match.  This would lead to misbehavior in various character string processing functions.Rerun initdb and either do not specify an encoding explicitly, or choose a matching combination.

 

[/CONSOLE]

 

I installed/uninstalled four time postgresql to change the parameter “local” to: POSIX, UTF8, Canada English (default), Canada French

 

I think that I need WIN1251 but I cannot figure out how to match the value of the “combobox” to those values:

http://www.postgresql.org/docs/8.4/static/multibyte.html

 

Can someone help point me out how to switch the local encoding?

 

Right now, all database are empty, we can uninstall/install postgresql. The specification is “LATIN1” for later use.

 

Thank YOU VERY MUCH!

Sébastien

 

Sébastien D’Errico

IT Development Consultant

Mobile : (438) 882-8687

Email : sebastien@hollox.net

 

Attachment

Re: create a database with encoding LATIN1

From
Grzegorz Szpetkowski
Date:
To use 'LATIN1 encoding you need compatible locale. You can specify it
at initdb stage as for example:

>initdb --locale en_CA.ISO-8859-1 -E LATIN1 -d D:/data # -E LATIN1 is redundant in such case

Futhermore since PostgreSQL 8.4 you can specify LC_COLLATE and
LC_CTYPE with CREATE DATABASE command (and createdb wrapper), so these
settings are not "frozen" with database cluster.

Regards,
Grzegorz Szpetkowski

2011/5/3 Sébastien D'Errico <sebastien@hollox.net>:
> Hello everyone!
>
>
>
> I read several old messages about encoding. I consult the documentation
> about initdb and the light bulb still does not “click” over my head.
>
>
>
> I installed Postgres 8.4 on Windows 2008.
>
>
>
> I am trying to create a database with encoding LATIN1. This is the result
> when I list all database:
>
>
>
> [CONSOLE]
>
>
>
>>psql -Upostgres –l
>
>
>
>    Name    |    Owner    | Encoding  |      Collation      |
> Ctype        |    Access privileges
>
> -----------+-------------+-----------+---------------------+---------------------+--------------------------
>
> postgres  | postgres    | UTF8      | English_Canada.1252 |
> English_Canada.1252 |
>
> sderrico  | _postgresql | SQL_ASCII | English_Canada.1252 |
> English_Canada.1252 |
>
> template0 | postgres    | UTF8      | English_Canada.1252 |
> English_Canada.1252 | =c/postgres : postgres=CTc/postgres
>
> template1 | postgres    | UTF8      | English_Canada.1252 |
> English_Canada.1252 | postgres=CTc/postgres : _postgresql=CTc/postgres
>
> test1     | postgres    | UTF8      | English_Canada.1252 |
> English_Canada.1252 |
>
>
>
> [/CONSOLE]
>
>
>
> This is the error message that I got when I tried to create the database:
>
>
>
> [CONSOLE]
>
>
>
>>create database test2 ENCODING='LATIN1';
>
>
>
> ERROR:  encoding LATIN1 does not match locale English_Canada.1252
>
> DETAIL:  The chosen LC_CTYPE setting requires encoding WIN1252.
>
>
>
> [/CONSOLE]
>
>
>
> So I tried to change the encoding:
>
>
>
> [CONSOLE]
>
>
>
>>initdb -E LATIN1 -d D:/data
>
>
>
> initdb: encoding mismatch
>
> The encoding you selected (LATIN1) and the encoding that the selected locale
> uses (WIN1252) do not match.  This would lead to misbehavior in various
> character string processing functions.Rerun initdb and either do not specify
> an encoding explicitly, or choose a matching combination.
>
>
>
> [/CONSOLE]
>
>
>
> I installed/uninstalled four time postgresql to change the parameter “local”
> to: POSIX, UTF8, Canada English (default), Canada French
>
>
>
> I think that I need WIN1251 but I cannot figure out how to match the value
> of the “combobox” to those values:
>
> http://www.postgresql.org/docs/8.4/static/multibyte.html
>
>
>
> Can someone help point me out how to switch the local encoding?
>
>
>
> Right now, all database are empty, we can uninstall/install postgresql. The
> specification is “LATIN1” for later use.
>
>
>
> Thank YOU VERY MUCH!
>
> Sébastien
>
>
>
> Sébastien D’Errico
>
> IT Development Consultant
>
> Mobile : (438) 882-8687
>
> Email : sebastien@hollox.net
>
>