Re: Move data between two databases SQL-ASCII to UTF8

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Chad Wagner <chad(dot)wagner(at)gmail(dot)com>
Cc: Clodoaldo <clodoaldo(dot)pinto(dot)neto(at)gmail(dot)com>, "MargaretGillon(at)chromalloy(dot)com" <MargaretGillon(at)chromalloy(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Move data between two databases SQL-ASCII to UTF8
Date: 2007-02-09 03:28:46
Message-ID: 20070209032845.GA98330@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Feb 08, 2007 at 08:22:40PM -0500, Chad Wagner wrote:
> On 2/8/07, Clodoaldo <clodoaldo(dot)pinto(dot)neto(at)gmail(dot)com> wrote:
> >Use pg_dump to dump the db and use iconv on the generated file:
> >
> >iconv -f ASCII -t UTF-8 mydb.dump -o mydb_utf8.dump

Converting the data from ASCII to UTF-8 doesn't make much sense:
if the data is ASCII then it doesn't need conversion; if the data
needs conversion then it isn't ASCII.

> Wouldn't it be adequate to set the client encoding to SQL_ASCII in the dump
> file (if that was infact the encoding on the original database)?

http://www.postgresql.org/docs/8.2/interactive/multibyte.html#AEN24118

"If the client character set is defined as SQL_ASCII, encoding
conversion is disabled, regardless of the server's character set."

As Clodoaldo mentioned, if the data is strictly ASCII then no
conversion is necessary because the UTF-8 representation will be
the same. If you set client_encoding to SQL_ASCII and the data
contains non-ASCII characters that aren't valid UTF-8 then you'll
get the error 'invalid byte sequence for encoding "UTF8"'. In that
case set client_encoding to whatever encoding the data is really
in; likely guesses for Western European languages are LATIN1, LATIN9,
or perhaps WIN1252.

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2007-02-09 04:18:26 Re: Adding TEXT columns tanks performance?
Previous Message Arturo Perez 2007-02-09 02:50:18 Adding TEXT columns tanks performance?