Unix Technical Forum

Finding bad bye in "invalid byte sequence" error

This is a discussion on Finding bad bye in "invalid byte sequence" error within the Pgsql General forums, part of the PostgreSQL category; --> Hi all, I'm trying to hack my inserts script from mssql to work with postgres 8.1.9 - I can ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 11:15 PM
robert
 
Posts: n/a
Default Finding bad bye in "invalid byte sequence" error

Hi all,

I'm trying to hack my inserts script from mssql to work with postgres
8.1.9 - I can upgrade if need be. I'm getting this error:

psql -h localhost atdev < fuk2.sql
ERROR: invalid byte sequence for encoding "UTF8": 0xe1204f
HINT: This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encoding".

I tried:

/var/lib/pgsql> recode ascii..utf8 fuk2.sql
recode: fuk2.sql failed: Invalid input in step `ANSI_X3.4-1968..UTF-8'

And also dos2unix , but nothing is working. 0xe1204f looks like a hex
address, and I'm trying hexdump to find what its complaining about,
but that's not helping either. Any ideas?

Robert
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 11:15 PM
Douglas McNaught
 
Posts: n/a
Default Re: Finding bad bye in "invalid byte sequence" error

On 12/13/07, robert <robertlazarski@gmail.com> wrote:
> Hi all,
>
> I'm trying to hack my inserts script from mssql to work with postgres
> 8.1.9 - I can upgrade if need be. I'm getting this error:
>
> psql -h localhost atdev < fuk2.sql
> ERROR: invalid byte sequence for encoding "UTF8": 0xe1204f
> HINT: This error can also happen if the byte sequence does not match
> the encoding expected by the server, which is controlled by
> "client_encoding".


The cleanest way to fix this is to figure out what encoding the data
in your SQL script is (since I am assuming parts of it were dumped
directly out of MSSQL) and set client_encoding to that. Your data is
almost certainly not straight 7-bit ASCII.

-Doug

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 11:15 PM
Tom Lane
 
Posts: n/a
Default Re: Finding bad bye in "invalid byte sequence" error

robert <robertlazarski@gmail.com> writes:
> I'm getting this error:


> psql -h localhost atdev < fuk2.sql
> ERROR: invalid byte sequence for encoding "UTF8": 0xe1204f
> HINT: This error can also happen if the byte sequence does not match
> the encoding expected by the server, which is controlled by
> "client_encoding".


Well, that isn't UTF8, and it isn't plain ASCII either. I'm betting
it's a single-byte encoding, probably one of the ISO-8859 series.
Have you looked at the data to see what *you* think the character is?
(Feed the script to psql with -f, not <, to get a line number for
the error.)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 11:15 PM
Adrian Klaver
 
Posts: n/a
Default Re: Finding bad bye in "invalid byte sequence" error

On Thursday 13 December 2007 10:38 am, robert wrote:
> Hi all,
>
> I'm trying to hack my inserts script from mssql to work with postgres
> 8.1.9 - I can upgrade if need be. I'm getting this error:
>
> psql -h localhost atdev < fuk2.sql
> ERROR: invalid byte sequence for encoding "UTF8": 0xe1204f
> HINT: This error can also happen if the byte sequence does not match
> the encoding expected by the server, which is controlled by
> "client_encoding".
>
> I tried:
>
> /var/lib/pgsql> recode ascii..utf8 fuk2.sql
> recode: fuk2.sql failed: Invalid input in step `ANSI_X3.4-1968..UTF-8'
>
> And also dos2unix , but nothing is working. 0xe1204f looks like a hex
> address, and I'm trying hexdump to find what its complaining about,
> but that's not helping either. Any ideas?
>
> Robert
>

I had a similiar problem and found I had to set the client encoding as
follows:

SET client_encoding = 'windows-1252';

at the top of my import file.


--
Adrian Klaver
aklaver@comcast.net

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:44 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com