Re: COPY 'invalid byte sequence for encoding "UTF8": 0xff' - Mailing list pgsql-general

From Steve Crawford
Subject Re: COPY 'invalid byte sequence for encoding "UTF8": 0xff'
Date
Msg-id 49EE04E0.6070702@pinpointresearch.com
Whole thread Raw
In response to COPY 'invalid byte sequence for encoding "UTF8": 0xff'  (Chris Worley <chris.worley@timco.aero>)
Responses Re: COPY 'invalid byte sequence for encoding "UTF8": 0xff'
List pgsql-general
Chris Worley wrote:
> Hello,
>
> I get the following error when running a sql script containing a COPY command:
>
> ERROR:  invalid byte sequence for encoding "UTF8": 0xff...
>
> The data I have contains binary data from a tcp dump....
>
> Does anybody know how the dump pulls a column with binary data?  It is
> a varchar column
No, if it it binary data, you need a column of type bytea and you need
to escape the appropriate characters in your input. For example, if I
create a table with a single bytea column called "foo" and insert the a
record with value "^F^O^O" then dump it, the dump will have the following:

COPY byteatest (foo) FROM stdin;
\\006\\017\\017
\.

See http://www.postgresql.org/docs/8.3/static/datatype-binary.html for
the characters that need to be escaped.

Cheers,
Steve


pgsql-general by date:

Previous
From: Chris Worley
Date:
Subject: COPY 'invalid byte sequence for encoding "UTF8": 0xff'
Next
From: Chris Worley
Date:
Subject: Re: COPY 'invalid byte sequence for encoding "UTF8": 0xff'