Re: psql weird behaviour with charset encodings - Mailing list pgsql-general

From hernan gonzalez
Subject Re: psql weird behaviour with charset encodings
Date
Msg-id s2v48692c2d1005071521w1a272409t5c26d3fc9011f732@mail.gmail.com
Whole thread Raw
In response to Re: psql weird behaviour with charset encodings  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: psql weird behaviour with charset encodings  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Mmm no:  \x displays correctly for me because it sends
 the raw text (in LATIN9) and I have set my terminal in LATIN9 (or ISO-8859-15)

And it's not that "xterm is misdisplaying" the text, it just that psql
is ouputting
an EMPTY (zero lenght) string for that field.
(I can even send the output to a file with \o, and check it in hexadecimal,
to re-verify  that it's not a terminal problem - it's not).

The issue is that psql tries (apparently) to convert to UTF8
(even when he plans to output the raw text -LATIN9 in this case)
just for computing the lenght of the field, to build the table.
And because for this computation he (apparently) rely on the string
routines with it's own locale, instead of the DB or client encoding.

That's why no problem arises with the \x switch.

I believe this is wrong, because when the client does not specify
an encoding, no conversion should be attempted.

Hernán

>
> Well, that's what it's doing (given the default setting with
> client_encoding equal to server_encoding), and then xterm is
> misdisplaying the text because xterm thinks it's utf8.  I'm
> not very clear on why the \x case seems to display correctly
> anyway, but you really need the terminal's encoding to agree
> with client_encoding in order to get non-ASCII characters to
> work well.
>
>                        regards, tom lane
>



--
Hernán J. González
http://hjg.com.ar/

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: psql weird behaviour with charset encodings
Next
From: Tom Lane
Date:
Subject: Re: initdb fails on Centos 5.4 x64