Re: invalid byte sequence for encoding error

From: "Oliver A(dot) Rojo" <oliverrojo(at)anticogroup(dot)com>
To: Markus Wollny <Markus(dot)Wollny(at)computec(dot)de>
Cc: Postgresql Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: invalid byte sequence for encoding error
Date: 2006-05-19 10:58:40
Message-ID: 446DA4E0.1050407@anticogroup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Markus Wollny wrote:

>Nis Jorgensen wrote:
>
>
>>Oliver A. Rojo wrote:
>>
>>
>>>how do you fix your original db?
>>>
>>>
>>>
>>Since I had only 3 occurrences of the error, I used
>>hand-crafted update statements. The fact that the replacement
>>for the invalid characters was constant and plain ascii made
>>this very easy.
>>
>>If you have many occurrences of the error, or if you need to
>>do replacement based on the invalid bytes, things become
>>trickier. You might even be better of working on the dump
>>file directly using perl/<favourite scripting language>
>>
>>
>
>I had the exact same problem with my upgrade - and a lot more than just
>a couple of occurences. The solution is quite easy however, so if you're
>prepared to simply eliminate the offending bytes, you'll find that iconv
>will be a very fast solution. However at least on my systems (Debian
>Sarge) iconv didn't like my >5GB sized dump files. So in order to
>successfully reimport the dumps, I had to "split --line-bytese0m" the
>SQL-file, pass the parts through iconv -c -f UTF8 -t UTF8 and
>concatenate them back into one file again. There were no more errors on
>feeding the dump back into psql and I didn't come across any missing
>data during my tests, so this has definitely done the trick for me.
>
>You should be aware that this will simply omit the illegal byte
>sequences from the dump. So if you've got some string
>"foo[non-UTF-8-bytes]bar", it will be converted to a simple "foobar" in
>the result. So if you really need to keep things 100% accurate, you'll
>have to actually identify each of these byte-sequences, then find the
>corresponding UTF-8 representation and use some search&replace-scripting
>on the dump before reloading it.
>
>Kind regards
>
> Markus
>
>
>
>
ahh! the real problem is this: It usually says "invalid byte sequence
for encoding" error when it encounters Ñ character. What should I
supposed to do here?

--

Oliver A. Rojo

______________________________________________________________

This email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to
whom they are addressed. If you have received this email in error
please notify the system manager. Please note that any views or
opinions presented in this email are solely those of the author
and do not necessarily represent those of the company. Finally,
the recipient should check this email and any attachments for the
presence of viruses. The company accepts no liability for any
damage caused by any virus transmitted by this email.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Csaba Nagy 2006-05-19 11:03:12 allow LIMIT in UPDATE and DELETE
Previous Message jayati.biswas 2006-05-19 10:29:48 problem with pg_restore