Re: Client Encoding and Latin characters - Mailing list pgsql-general

From Tom Lane
Subject Re: Client Encoding and Latin characters
Date
Msg-id 18502.1259081121@sss.pgh.pa.us
Whole thread Raw
In response to Client Encoding and Latin characters  (Lee Hachadoorian <lee.hachadoorian@gmail.com>)
Responses Re: Client Encoding and Latin characters  (Lee Hachadoorian <lee.hachadoorian@gmail.com>)
List pgsql-general
Lee Hachadoorian <lee.hachadoorian@gmail.com> writes:
> My database is encoded UTF8. I recently was uploading (via COPY) some
> census data which included place names with �, �, �, and other such
> characters. The upload choked on the Latin characters. Following the
> docs, I was able to fix this with:

> SET CLIENT_ENCODING TO 'LATIN1';
> COPY table FROM 'filename';

> After which I

> SET CLIENT_ENCODING TO 'UTF8';

> I typically use COPY FROM to bulk load data. My question is, is there
> any disadvantage to setting the default client_encoding as LATIN1? I
> expect to never be dealing with Asian languages, or most of the other
> LATINx languages. If I ever try to COPY FROM data incompatible with
> LATIN1, the command will just choke, and I can pick an appropriate
> encoding and try again, right?

Uh, no.  You can pretty much assume that LATIN1 will take any random
byte string; likewise for any other single-byte encoding.  UTF8 as a
default is a bit safer because it's significantly more likely that it
will be able to detect non-UTF8 input.

            regards, tom lane

pgsql-general by date:

Previous
From: Lee Hachadoorian
Date:
Subject: Client Encoding and Latin characters
Next
From: Andrej
Date:
Subject: Re: ora2pg and DBD::Pg