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

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Move data between two databases SQL-ASCII to UTF8
Дата
Msg-id 20070209032845.GA98330@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Move data between two databases SQL-ASCII to UTF8  ("Chad Wagner" <chad.wagner@gmail.com>)
Список pgsql-general
On Thu, Feb 08, 2007 at 08:22:40PM -0500, Chad Wagner wrote:
> On 2/8/07, Clodoaldo <clodoaldo.pinto.neto@gmail.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

В списке pgsql-general по дате отправления:

Предыдущее
От: Madison Kelly
Дата:
Сообщение: Possibly odd question; diff results?
Следующее
От: Arturo Perez
Дата:
Сообщение: Adding TEXT columns tanks performance?