Re: Problem of a server gettext message. - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Problem of a server gettext message.
Date
Msg-id 200712101925.53865.peter_e@gmx.net
Whole thread Raw
In response to Re: Problem of a server gettext message.  ("Hiroshi Saito" <z-saito@guitar.ocn.ne.jp>)
Responses Re: Problem of a server gettext message.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Am Montag, 10. Dezember 2007 schrieb Hiroshi Saito:
> Hi.
>
> From: "Peter Eisentraut" <peter_e@gmx.net>
>
> > Am Montag, 10. Dezember 2007 schrieb Hiroshi Saito:
> >> Hi Peter-san.
> >>
> >> It is this.
> >> http://winpg.jp/~saito/pg83/ja.zip
> >
> > Sorry, we need the *po* (text) files, not the *mo* (binary) files.
>
> Ooops, Although it is an object for Version 8.2.5.
> http://www.postgresql.jp/wg/jpugdoc/po/postgresql-8-2-5-nls-patch.gz

OK, you have

PO file in EUC-JP
server encoding UTF-8
client encoding SJIS

When the server wants to send an error message to the client, it will convert 
them from the server to the client encoding.  The English messages are ASCII, 
so this will work, because server encodings are required to be ASCII 
compatible.  The result of the gettext calls, however, is encoded in EUC-JP, 
so the server will take the EUC-JP bytes and attempt to do a UTF-8 to SJIS 
conversion on them.  This will cause a crash.

What you need to do is set the locale to something compatible with the server 
encoding (e.g., ja_JP.utf8).  Then gettext will recode its EUC-JP data to 
UTF-8 before it is sent to the server.  More specifically, you need to set 
the LC_CTYPE locale category to make this happen.  I understand that users in 
Japanese environments like to keep the LC_COLLATE setting to C, and you 
should still be able to do that.  But without a proper LC_CTYPE setting, this 
will not work.

(That is the explanation for Linux.  Windows might be different in the 
details, but I suspect it has the same mechanisms.)

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Release Note Changes
Next
From: Alvaro Herrera
Date:
Subject: Re: archive_command failures report confusing exit status