Обсуждение: default client_encoding with psql on windows

Поиск
Список
Период
Сортировка

default client_encoding with psql on windows

От
"Thomas Sondag"
Дата:
hi all,

I try to solve a litle problem, with PostgreSQL 8.1.3 on windows with UTF8.

I read all the documentation related to psql on windows, I turn my cmd.exe encoding to codepage 1252 with the good font.

When I try a connection to my UTF8 database with psql (with my windows cp1252 terminal) I have some problems like \d produce an error : "ERROR:  invalid UTF-8 byte sequence detected near byte 0xe9", because my client_encoding is set to UTF8.

So I try to set my encoding to "win1252" with \encoding win1252 and it's work beter. I would like to set it by default but for psql only (all other programs speak UTF8).

I tried various things with the --set option of psql without success, like
--set client_encoding=win1252 or --set CLIENT_ENCODING=win1252 or --set encoding=win1252.

I think my syntax is good but that doesn't work.

This part of the man page doesn't sound realy good to me (concerning the --set option) :
"These assignments  are  done
during a very early stage of start-up, so variables reserved for
internal purposes might get overwritten later."


But you are my last change before reading the source code, so please tell me  if you have any clue :)


  Thomas

Re: default client_encoding with psql on windows

От
John DeSoi
Дата:
On May 8, 2006, at 12:14 PM, Thomas Sondag wrote:

> I tried various things with the --set option of psql without
> success, like
> --set client_encoding=win1252 or --set CLIENT_ENCODING=win1252 or --
> set encoding=win1252.


The variables are case sensitive, so it looks like you left out the
right one. The docs say the psql variable is ENCODING (all caps).

If that does not work maybe you could call \encoding in the psqlrc file?




John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


Re: default client_encoding with psql on windows

От
John DeSoi
Дата:
[Don't forget to CC the list so everyone can see your reply]

The pgInstaller uses Wix which is open source. You can download it
from Source Forge.

John



On May 10, 2006, at 7:23 AM, Thomas Sondag wrote:

> 2006/5/10, John DeSoi <desoi@pgedit.com>:
>>
>> On May 8, 2006, at 12:14 PM, Thomas Sondag wrote:
>>
>> > I tried various things with the --set option of psql without
>> > success, like
>> > --set client_encoding=win1252 or --set CLIENT_ENCODING=win1252
>> or --
>> > set encoding=win1252.
>>
>>
>> The variables are case sensitive, so it looks like you left out the
>> right one. The docs say the psql variable is ENCODING (all caps).
>
> --set ENCODING=win1252 doesn't work
>>
>> If that does not work maybe you could call \encoding in the psqlrc
>> file?
>
> \encoding win1252 in psqlrc.conf do the work, thanks for the clue.
> But it may have some side effect with psql.exe in a shell script (like
> importing data in UTF8).
>
> Today I find one environement variable in the pg_dump man page :
> PGCLIENTENCODING
>
> This shortcut solve most of my problems :
> C:\WINDOWS\system32\cmd.exe /k chcp 1252 && set PGPORT=5432 && set
> PGCLIENTENCODING=win1252 &&"C:\Program
> Files\PostgreSQL\8.1\bin\psql.exe"  -h localhost -p 5432 postgres
> "postgres"
>
> I think this shorcut could solve a lot of isue, with PostgreSQL on
> Windows.
>
> I would like to modify the PostgreSQL msi myself to replace the
> default psql link with that one, but I don't have the tool to do it.
>
> I will post a bug report for Pginstaller.
>
> Thanks
>
>   Thomas



John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL