pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
invalid byte sequence for encoding "UTF8": 0xff
18+ messages / 12 participants
[nested] [flat]

* invalid byte sequence for encoding "UTF8": 0xff
@ 2007-09-03 08:06  Ashish Karalkar <ashish.karalkar@info-spectrum.com>
  0 siblings, 2 replies; 18+ messages in thread

From: Ashish Karalkar @ 2007-09-03 08:06 UTC (permalink / raw)
  To: pgsql-general

Hello All,

I have a data script which runs fine from PgAdmin SQL Editor,but when I  run this  from command prompt I get following error:


test=# \i /usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql

psql:/usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql:1: ERROR:  invalid byt
e sequence for encoding "UTF8": 0xff
HINT:  This error can also happen if the byte sequence does not match the encodi
ng expected by the server, which is controlled by "client_encoding".


can anybody suggest me what is going wrong.
database  encoding :UTF8

PostgreSQL details:

 version
-------------------------------------------------------------------------------------------------------
 PostgreSQL 8.2.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: invalid byte sequence for encoding "UTF8": 0xff
@ 2007-09-03 08:15  Martijn van Oosterhout <kleptog@svana.org>
  parent: Ashish Karalkar <ashish.karalkar@info-spectrum.com>
  1 sibling, 0 replies; 18+ messages in thread

From: Martijn van Oosterhout @ 2007-09-03 08:15 UTC (permalink / raw)
  To: Ashish Karalkar <ashish.karalkar@info-spectrum.com>; +Cc: pgsql-general

On Mon, Sep 03, 2007 at 01:36:58PM +0530, Ashish Karalkar wrote:
> Hello All,
> 
> I have a data script which runs fine from PgAdmin SQL Editor,but when I  run this  from command prompt I get following error:
> test=# \i /usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql
> 
> psql:/usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql:1: ERROR:  invalid byt
> e sequence for encoding "UTF8": 0xff
> HINT:  This error can also happen if the byte sequence does not match the encodi
> ng expected by the server, which is controlled by "client_encoding".

Well, the error is correct, that's not a valid UTF-8 character. I seem
to remember someone saying that ooasionally windows puts BOMs in UTF-8
files (which is completely bogus). Check the file using a simple text
editor a check if there are some odd characters at the beginning of the
file.

Have a ncie day,
-- 
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachments:

  signature.asc (application/pgp-signature, 188B) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: invalid byte sequence for encoding "UTF8": 0xff
@ 2007-09-03 08:42  Albe Laurenz <all@adv.magwien.gv.at>
  parent: Ashish Karalkar <ashish.karalkar@info-spectrum.com>
  1 sibling, 0 replies; 18+ messages in thread

From: Albe Laurenz @ 2007-09-03 08:42 UTC (permalink / raw)
  To: Ashish Karalkar *EXTERN* <ashish.karalkar@info-spectrum.com>; pgsql-general

Ashish Karalkar wrote:
> I have a data script which runs fine from PgAdmin SQL 
> Editor,but when I  run this  from command prompt I get 
> following error:
>  
>  
> test=# \i /usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql
> 
> psql:/usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql:1: 
> ERROR:  invalid byte sequence for encoding "UTF8": 0xff
> 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".
>  
> can anybody suggest me what is going wrong.
> database  encoding :UTF8
>  
> PostgreSQL details:
>  
>  version
> --------------------------------------------------------------
>  PostgreSQL 8.2.0 on i686-pc-linux-gnu, compiled by GCC gcc 
> (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

Can you tell us the following:

- What is the client operating system (where you run psql and
  PgAdmin III)?
- What is the value of the environment variable PGCLIENTENCODING
  set to on the client?
- What does the SQL command "show client_encoding;" return
  when you issue it in
  a) PgAdmin III
  b) psql
- Please create a file that contains only the first line
  of QSWEB_100_4_Default_Data.sql (I call it "l" in the following
  commands), run the following two (Linux) commands on it:
  a) od -t c l
  b) od -t x1 l
  and show us the output of both commands.

Yours,
Laurenz Albe



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: invalid byte sequence for encoding "UTF8": 0xff
@ 2007-09-03 10:47  Ashish Karalkar <ashish.karalkar@info-spectrum.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Ashish Karalkar @ 2007-09-03 10:47 UTC (permalink / raw)
  To: Albe Laurenz <all@adv.magwien.gv.at>; +Cc: pgsql-general


----- Original Message ----- 
From: "Ashish Karalkar" <ashish.karalkar@info-spectrum.com>
To: "Albe Laurenz" <all@adv.magwien.gv.at>
Sent: Monday, September 03, 2007 4:09 PM
Subject: Re: [GENERAL] invalid byte sequence for encoding "UTF8": 0xff


>
> ----- Original Message ----- 
> From: "Albe Laurenz" <all@adv.magwien.gv.at>
> To: "Ashish Karalkar *EXTERN*" <ashish.karalkar@info-spectrum.com>; 
> <pgsql-general@postgresql.org>
> Sent: Monday, September 03, 2007 2:12 PM
> Subject: Re: [GENERAL] invalid byte sequence for encoding "UTF8": 0xff
>
>
> Ashish Karalkar wrote:
>> I have a data script which runs fine from PgAdmin SQL
>> Editor,but when I  run this  from command prompt I get
>> following error:
>>
>>
>> test=# \i /usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql
>>
>> psql:/usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql:1:
>> ERROR:  invalid byte sequence for encoding "UTF8": 0xff
>> 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".
>>
>> can anybody suggest me what is going wrong.
>> database  encoding :UTF8
>>
>> PostgreSQL details:
>>
>>  version
>> --------------------------------------------------------------
>>  PostgreSQL 8.2.0 on i686-pc-linux-gnu, compiled by GCC gcc
>> (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
>
> Can you tell us the following:
>
> Please find my answer below
>
> - What is the client operating system (where you run psql and
>  PgAdmin III)?
>
> Its Windows XP - PgAdmin III
> RHEL 3.4.3-9.EL4-psql (Server Machine)
>
>
> - What is the value of the environment variable PGCLIENTENCODING
>  set to on the client?
> PGCLIENTENCODING is not set and as per documantation I think by default it 
> takes value of database i.e. UTF8
>
> - What does the SQL command "show client_encoding;" return
>  when you issue it in
>  a) PgAdmin III
> UNICODE
>  b) psql
> UTF8
>
> - Please create a file that contains only the first line
>  of QSWEB_100_4_Default_Data.sql (I call it "l" in the following
>  commands), run the following two (Linux) commands on it:
>  a) od -t c l
>  b) od -t x1 l
>  and show us the output of both commands.
>
>
> [root@localhost qsweb]# od -t c test.sql
> 0000000   \   s   e   t       O   N   _   E   R   R   O   R   _   S   T
> 0000020   O   P
> 0000022
> [root@localhost qsweb]# od -t x1 test.sql
> 0000000 5c 73 65 74 20 4f 4e 5f 45 52 52 4f 52 5f 53 54
> 0000020 4f 50
> 0000022
> [root@localhost qsweb]#
>
> Thanks Albe for your replay.
> here is the data you wanted
>
>
> Yours,
> Laurenz Albe
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>               http://archives.postgresql.org/ 




^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: invalid byte sequence for encoding "UTF8": 0xff
@ 2007-09-03 11:24  Albe Laurenz <all@adv.magwien.gv.at>
  parent: Ashish Karalkar <ashish.karalkar@info-spectrum.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Albe Laurenz @ 2007-09-03 11:24 UTC (permalink / raw)
  To: Ashish Karalkar *EXTERN* <ashish.karalkar@info-spectrum.com>; +Cc: pgsql-general

Ashish Karalkar wrote:
>>> I have a data script which runs fine from PgAdmin SQL
>>> Editor,but when I  run this  from command prompt I get
>>> following error:
>>>
>>> test=# \i /usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql
>>>
>>> psql:/usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql:1:
>>> ERROR:  invalid byte sequence for encoding "UTF8": 0xff
>>>
>>>  version
>>> --------------------------------------------------------------
>>>  PostgreSQL 8.2.0 on i686-pc-linux-gnu, compiled by GCC gcc
>>> (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
>>
>> - What is the client operating system (where you run psql and
>>  PgAdmin III)?
>>
> Its Windows XP - PgAdmin III
> RHEL 3.4.3-9.EL4-psql (Server Machine)

So I get it that you run "psql" on Windows XP, right?

> PGCLIENTENCODING is not set and as per documantation I 
> think by default it takes value of database i.e. UTF8
>
>> - What does the SQL command "show client_encoding;" return
>>  when you issue it in
>>  a) PgAdmin III
> UNICODE
>>  b) psql
> UTF8

Ok, I suspect that's your problem.
You created QSWEB_100_4_Default_Data.sql by using the "Save" dialog
in PgAdmin III on the Windows machine, right?

Then the file will probably be encoded in Windows-1252.

If your client_encoding is set to UTF8, psql will expect UTF-8
data in the SQL script and complain if it meets wrong ones.

Does the script work as expected when you change the client
encoding to WIN1252?

>> - Please create a file that contains only the first line
>>  of QSWEB_100_4_Default_Data.sql (I call it "l" in the following
>>  commands), run the following two (Linux) commands on it:
>>  a) od -t c l
>>  b) od -t x1 l
>>  and show us the output of both commands.
>
> [root@localhost qsweb]# od -t c test.sql
> 0000000   \   s   e   t       O   N   _   E   R   R   O   R   _   S
T
> 0000020   O   P
> 0000022
> [root@localhost qsweb]# od -t x1 test.sql
> 0000000 5c 73 65 74 20 4f 4e 5f 45 52 52 4f 52 5f 53 54
> 0000020 4f 50
> 0000022

That's weird, because psql complained about line 1.

Maybe you messed something up by extracting the first line.

Try the following:

- Use binary file transfer and transfer the SQL script to a Linux
machine.

- Run "od -t c -t x1" on the file

- Find the 0xff that psql complains about.

Maybe that helps to locate the problem.
0xff is an unusual Windows-1252 character as well...

Yours,
Laurenz Albe



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: invalid byte sequence for encoding "UTF8": 0xff
@ 2007-09-03 12:10  Ashish Karalkar <ashish.karalkar@info-spectrum.com>
  parent: Albe Laurenz <all@adv.magwien.gv.at>
  0 siblings, 0 replies; 18+ messages in thread

From: Ashish Karalkar @ 2007-09-03 12:10 UTC (permalink / raw)
  To: Albe Laurenz <all@adv.magwien.gv.at>; +Cc: pgsql-general


----- Original Message ----- 
From: "Albe Laurenz" <all@adv.magwien.gv.at>
To: "Ashish Karalkar *EXTERN*" <ashish.karalkar@info-spectrum.com>
Cc: <pgsql-general@postgresql.org>
Sent: Monday, September 03, 2007 4:54 PM
Subject: RE: [GENERAL] invalid byte sequence for encoding "UTF8": 0xff


Ashish Karalkar wrote:
>>> I have a data script which runs fine from PgAdmin SQL
>>> Editor,but when I  run this  from command prompt I get
>>> following error:
>>>
>>> test=# \i /usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql
>>>
>>> psql:/usr/local/pgsql/qsweb1/QSWEB_100_4_Default_Data.sql:1:
>>> ERROR:  invalid byte sequence for encoding "UTF8": 0xff
>>>
>>>  version
>>> --------------------------------------------------------------
>>>  PostgreSQL 8.2.0 on i686-pc-linux-gnu, compiled by GCC gcc
>>> (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
>>
>> - What is the client operating system (where you run psql and
>>  PgAdmin III)?
>>
> Its Windows XP - PgAdmin III
> RHEL 3.4.3-9.EL4-psql (Server Machine)

So I get it that you run "psql" on Windows XP, right?

> PGCLIENTENCODING is not set and as per documantation I 
> think by default it takes value of database i.e. UTF8
>
>> - What does the SQL command "show client_encoding;" return
>>  when you issue it in
>>  a) PgAdmin III
> UNICODE
>>  b) psql
> UTF8

Ok, I suspect that's your problem.
You created QSWEB_100_4_Default_Data.sql by using the "Save" dialog
in PgAdmin III on the Windows machine, right?

Then the file will probably be encoded in Windows-1252.

If your client_encoding is set to UTF8, psql will expect UTF-8
data in the SQL script and complain if it meets wrong ones.

Does the script work as expected when you change the client
encoding to WIN1252?

>> - Please create a file that contains only the first line
>>  of QSWEB_100_4_Default_Data.sql (I call it "l" in the following
>>  commands), run the following two (Linux) commands on it:
>>  a) od -t c l
>>  b) od -t x1 l
>>  and show us the output of both commands.
>
> [root@localhost qsweb]# od -t c test.sql
> 0000000   \   s   e   t       O   N   _   E   R   R   O   R   _   S
T
> 0000020   O   P
> 0000022
> [root@localhost qsweb]# od -t x1 test.sql
> 0000000 5c 73 65 74 20 4f 4e 5f 45 52 52 4f 52 5f 53 54
> 0000020 4f 50
> 0000022

That's weird, because psql complained about line 1.

Maybe you messed something up by extracting the first line.

Try the following:

- Use binary file transfer and transfer the SQL script to a Linux
machine.

- Run "od -t c -t x1" on the file

- Find the 0xff that psql complains about.

Maybe that helps to locate the problem.
0xff is an unusual Windows-1252 character as well...

Hey Thanks Albe it worked.


Yours,
Laurenz Albe



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* invalid byte sequence for encoding "UTF8": 0xf1612220
@ 2011-05-11 07:16  AI Rumman <rummandba@gmail.com>
  0 siblings, 1 reply; 18+ messages in thread

From: AI Rumman @ 2011-05-11 07:16 UTC (permalink / raw)
  To: pgsql-general

I am trying to migrate a database from Postgresql 8.2 to Postgresql 8.3 and
getting the following error:

pg_restore: [archiver (db)] Error from TOC entry 2764; 0 29708702 TABLE DATA
originaldata postgres
pg_restore: [archiver (db)] COPY failed: ERROR:  invalid byte sequence for
encoding "UTF8": 0xf1612220
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".
CONTEXT:  COPY wi_originaldata, line 3592

I took a dump from 8.2 server and then tried to restore at 8.3.

Both the client_encoding and server_encoding are UTF8 at both the servers.

                                            Table "public.data"
       Column        |          Type
|                               Modifiers
---------------------+------------------------+------------------------------------------------------------------------
 orgid               | integer                |
 id                  | integer                | not null default
nextval(('"data"'::text)::regclass)
 datatypecode        | character varying(15)  |
 batchname           | character varying(60)  |
 filename            | character varying(60)  |
 encoding            | character varying(20)  |
 errormessage        | character varying(255) |
 originaldata_backup | bytea                  |
 processeddata       | bytea                  |
 validatedflag       | smallint               |
 processedflag       | smallint               |
 createddate         | date                   |
 createdtime         | time without time zone |
 modifieddate        | date                   |
 modifiedtime        | time without time zone |
 processeddate       | date                   |
 processedtime       | time without time zone |
 deletedflag         | smallint               |
 originaldata        | text                   |
Indexes:
    "data_pkey" PRIMARY KEY, btree (id)

Any help will be appreciable.

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: invalid byte sequence for encoding "UTF8": 0xf1612220
@ 2011-05-12 02:52  Craig Ringer <craig@postnewspapers.com.au>
  parent: AI Rumman <rummandba@gmail.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Craig Ringer @ 2011-05-12 02:52 UTC (permalink / raw)
  To: AI Rumman <rummandba@gmail.com>; +Cc: pgsql-general

On 05/11/2011 03:16 PM, AI Rumman wrote:
> I am trying to migrate a database from Postgresql 8.2 to Postgresql 8.3
> and getting the following error:
>
> pg_restore: [archiver (db)] Error from TOC entry 2764; 0 29708702 TABLE
> DATA originaldata postgres
> pg_restore: [archiver (db)] COPY failed: ERROR:  invalid byte sequence
> for encoding "UTF8": 0xf1612220
> 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".
> CONTEXT:  COPY wi_originaldata, line 3592
>
> I took a dump from 8.2 server and then tried to restore at 8.3.
>
> Both the client_encoding and server_encoding are UTF8 at both the servers.

Newer versions of Pg got better at caching bad unicode. While this helps 
prevent bad data getting into the database, it's a right pain if you're 
moving data over from an older version with less strict checks.

I don't know of any way to relax the checks for the purpose of importing 
dumps. You'll need to fix your dump files before loading them (by 
finding the faulty text and fixing it) or fix it in the origin database 
before migrating the data. Neither approach is nice or easy, but nobody 
has yet stepped up to write a unicode verifier tool that checks old 
databases' text fields against stricter rules...

--
Craig Ringer



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: invalid byte sequence for encoding "UTF8": 0xf1612220
@ 2011-05-12 08:32  Cédric Villemain <cedric.villemain.debian@gmail.com>
  parent: Craig Ringer <craig@postnewspapers.com.au>
  0 siblings, 0 replies; 18+ messages in thread

From: Cédric Villemain @ 2011-05-12 08:32 UTC (permalink / raw)
  To: Craig Ringer <craig@postnewspapers.com.au>; +Cc: AI Rumman <rummandba@gmail.com>; pgsql-general

2011/5/12 Craig Ringer <craig@postnewspapers.com.au>:
> On 05/11/2011 03:16 PM, AI Rumman wrote:
>>
>> I am trying to migrate a database from Postgresql 8.2 to Postgresql 8.3
>> and getting the following error:
>>
>> pg_restore: [archiver (db)] Error from TOC entry 2764; 0 29708702 TABLE
>> DATA originaldata postgres
>> pg_restore: [archiver (db)] COPY failed: ERROR:  invalid byte sequence
>> for encoding "UTF8": 0xf1612220
>> 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".
>> CONTEXT:  COPY wi_originaldata, line 3592
>>
>> I took a dump from 8.2 server and then tried to restore at 8.3.
>>
>> Both the client_encoding and server_encoding are UTF8 at both the servers.
>
> Newer versions of Pg got better at caching bad unicode. While this helps
> prevent bad data getting into the database, it's a right pain if you're
> moving data over from an older version with less strict checks.
>
> I don't know of any way to relax the checks for the purpose of importing
> dumps. You'll need to fix your dump files before loading them (by finding
> the faulty text and fixing it) or fix it in the origin database before
> migrating the data. Neither approach is nice or easy, but nobody has yet
> stepped up to write a unicode verifier tool that checks old databases' text
> fields against stricter rules...


The 2 following articles have SQL functions and documentation you may
find useful:

http://tapoueh.org/articles/blog/_Getting_out_of_SQL_ASCII,_part_1.html
http://tapoueh.org/articles/blog/_Getting_out_of_SQL_ASCII,_part_2.html


>
> --
> Craig Ringer
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>



-- 
Cédric Villemain               2ndQuadrant
http://2ndQuadrant.fr/     PostgreSQL : Expertise, Formation et Support



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Invalid byte sequence for encoding "UTF8": 0xedbebf
@ 2011-06-15 20:18  BRUSSER Michael <Michael.BRUSSER@3ds.com>
  0 siblings, 2 replies; 18+ messages in thread

From: BRUSSER Michael @ 2011-06-15 20:18 UTC (permalink / raw)
  To: pgsql-general

This is a follow-up on my previous message http://archives.postgresql.org/pgsql-general/2011-06/msg00054.php

I think I have now some understanding of what's causing the problem, but I don't have a good solution, instead more questions.
The release notes for v8.1 at http://www.postgresql.org/docs/current/interactive/release-8-1.html
make a good suggestion on using iconv to convert the plain-text dump file into utf8
On Linux this did not work, the input and output file were identical. The iconv on Solaris  refused to open the input file
(probably too big),  although it worked with a chunk of it and reported conversion error.

Unless there's no other options I don't want to use sed or break file into pieces, if possible, I would prefer to identify the bad records on the database.
I tried SELECT with everything  I could think of:  ~*, SIMILAR TO, and the likes of them, but I never got it right.

Is there a way to find the records with the text field containing Unicode bytes "0xedbebf"?
Unfortunately this is a very old version 7.3.10

Thank you.
Michael.

This email and any attachments are intended solely for the use of the individual or entity to whom it is addressed and may be confidential and/or privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email and all attachments,

(iii) Dassault Systemes does not accept or assume any liability or responsibility for any use of or reliance on this email.

For other languages, go to http://www.3ds.com/terms/email-disclaimer

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Invalid byte sequence for encoding "UTF8": 0xedbebf
@ 2011-06-15 21:37  Alan Hodgson <ahodgson@simkin.ca>
  parent: BRUSSER Michael <Michael.BRUSSER@3ds.com>
  1 sibling, 1 reply; 18+ messages in thread

From: Alan Hodgson @ 2011-06-15 21:37 UTC (permalink / raw)
  To: pgsql-general

On June 15, 2011 01:18:27 PM BRUSSER Michael wrote:
> Unless there's no other options I don't want to use sed or break file into
> pieces, if possible,

iconv loads everything into RAM. You can use "split", convert the pieces, and 
then recombine, I did that when converting a large database to utf-8 and it 
worked.

-- 
Obama has now fired more cruise missiles than all other Nobel Peace prize 
winners combined.



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Invalid byte sequence for encoding "UTF8": 0xedbebf
@ 2011-06-15 21:44  BRUSSER Michael <Michael.BRUSSER@3ds.com>
  parent: Alan Hodgson <ahodgson@simkin.ca>
  0 siblings, 0 replies; 18+ messages in thread

From: BRUSSER Michael @ 2011-06-15 21:44 UTC (permalink / raw)
  To: Alan Hodgson <ahodgson@simkin.ca>; pgsql-general

-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Alan Hodgson
Sent: Wednesday, June 15, 2011 5:37 PM
To: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Invalid byte sequence for encoding "UTF8": 0xedbebf

On June 15, 2011 01:18:27 PM BRUSSER Michael wrote:
> Unless there's no other options I don't want to use sed or break file into
> pieces, if possible,

--------------------------------------------------

>> iconv loads everything into RAM. You can use "split", convert the pieces, and
>> then recombine, I did that when converting a large database to utf-8 and it
>> worked.

-------------------------------------------------

- Thanks, but this is exactly what I am trying to avoid!
Using split is good if you have one database to upgrade and no external customers.
(Not to mention other problems with this approach)

This email and any attachments are intended solely for the use of the individual or entity to whom it is addressed and may be confidential and/or privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email and all attachments,

(iii) Dassault Systemes does not accept or assume any liability or responsibility for any use of or reliance on this email.

For other languages, go to http://www.3ds.com/terms/email-disclaimer



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Invalid byte sequence for encoding "UTF8": 0xedbebf
@ 2011-06-16 09:15  Albe Laurenz <laurenz.albe@wien.gv.at>
  parent: BRUSSER Michael <Michael.BRUSSER@3ds.com>
  1 sibling, 1 reply; 18+ messages in thread

From: Albe Laurenz @ 2011-06-16 09:15 UTC (permalink / raw)
  To: BRUSSER Michael *EXTERN* <Michael.BRUSSER@3ds.com>; pgsql-general

BRUSSER Michael wrote:
> Is there a way to find the records with the text field containing
Unicode bytes "0xedbebf"?
>
> Unfortunately this is a very old version 7.3.10

This should work on 7.3 (according to the documentation):

SELECT id FROM nlsdata WHERE position('\360\235\204\236'::bytea IN
val::bytea) = 1;

Here "val" is the column containing the values in question.

Yours,
Laurenz Albe



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Invalid byte sequence for encoding "UTF8": 0xedbebf
@ 2011-06-16 17:32  BRUSSER Michael <Michael.BRUSSER@3ds.com>
  parent: Albe Laurenz <laurenz.albe@wien.gv.at>
  0 siblings, 1 reply; 18+ messages in thread

From: BRUSSER Michael @ 2011-06-16 17:32 UTC (permalink / raw)
  To: Albe Laurenz <laurenz.albe@wien.gv.at>; pgsql-general

-----Original Message-----
From: Albe Laurenz [mailto:laurenz.albe@wien.gv.at]
Sent: Thursday, June 16, 2011 5:16 AM
To: BRUSSER Michael; pgsql-general@postgresql.org
Subject: RE: [GENERAL] Invalid byte sequence for encoding "UTF8": 0xedbebf

BRUSSER Michael wrote:
> Is there a way to find the records with the text field containing Unicode bytes "0xedbebf"?
> Unfortunately this is a very old version 7.3.10

This should work on 7.3 (according to the documentation):
SELECT id FROM nlsdata WHERE position('\360\235\204\236'::bytea IN val::bytea) = 1;

--------------------------------------------------------------------------------

Albe, thanks for pointing this out!

I made a minor change, added decode since text cannot be cast to bytea and tried something like this:
  SELECT id FROM myTable WHERE position('\360\235\204\236'::bytea IN decode(myTextField, 'escape')) != 0
  ERROR:  decode: Bad input string for type bytea

If I limit query to some healthy records - " AND id between 100 and 110" it works and returns empty result.
So the problem now is that without decode myTextField cannot be converted to bytea, with decode it breaks on the first 'bad' value.
Maybe this explains why?
testdb=# select decode('\360\235\204\236'::text, 'escape');
ERROR:  Unicode >= 0x10000 is not supported

Another thought is that if I get this to work I may need to search for anything outside of the standard utf range,
rather than any specific sequence. I am beginning to understand why many people dealt with this in the dump file,
but I'm not ready to give up yet...

As usual, any ideas are appreciated!
Thanks.


This email and any attachments are intended solely for the use of the individual or entity to whom it is addressed and may be confidential and/or privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email and all attachments,

(iii) Dassault Systemes does not accept or assume any liability or responsibility for any use of or reliance on this email.

For other languages, go to http://www.3ds.com/terms/email-disclaimer



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Invalid byte sequence for encoding "UTF8": 0xedbebf
@ 2011-06-17 07:58  Albe Laurenz <laurenz.albe@wien.gv.at>
  parent: BRUSSER Michael <Michael.BRUSSER@3ds.com>
  0 siblings, 0 replies; 18+ messages in thread

From: Albe Laurenz @ 2011-06-17 07:58 UTC (permalink / raw)
  To: BRUSSER Michael *EXTERN* <Michael.BRUSSER@3ds.com>; pgsql-general

BRUSSER Michael wrote:
>>> Is there a way to find the records with the text field containing
Unicode bytes "0xedbebf"?
>>> Unfortunately this is a very old version 7.3.10
>>
>> This should work on 7.3 (according to the documentation):
>> SELECT id FROM nlsdata WHERE position('\360\235\204\236'::bytea IN
val::bytea) = 1;

> Albe, thanks for pointing this out!

> I made a minor change, added decode since text cannot be cast to bytea
and tried something like this:
>  SELECT id FROM myTable WHERE position('\360\235\204\236'::bytea IN
decode(myTextField, 'escape')) !=0
>  ERROR:  decode: Bad input string for type bytea

Hrm. I didn't know that there was no cast from text to bytea in 7.3.

> Maybe this explains why?
> testdb=# select decode('\360\235\204\236'::text, 'escape');
> ERROR:  Unicode >= 0x10000 is not supported

No, that is an error on my side. I gave you the wrong byte sequence.

For "0xedbebf" you should actually write '\355\276\277'. But that's no
valid UTF-8 sequence.

> but I'm not ready to give up yet...

If you know the byte sequence that causes trouble, you could also use
something like "sed"
to search and replace it in the dump file.

Or (if there are not too many) you could search for the pattern and
identify the rows
in the database. Then you know which database rows to update.

Yours,
Laurenz Albe



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* invalid byte sequence for encoding "UTF8": 0x00
@ 2011-11-19 17:32  pawel_kukawski <kukismen@gmail.com>
  0 siblings, 1 reply; 18+ messages in thread

From: pawel_kukawski @ 2011-11-19 17:32 UTC (permalink / raw)
  To: pgsql-general

Hi,

Is there any way I can store NULL character (\u0000) in string ?

Or there is only one option that I have change every text field to bytea.

Regards,
Paweł

--
View this message in context: http://postgresql.1045698.n5.nabble.com/invalid-byte-sequence-for-encoding-UTF8-0x00-tp5007173p50071...
Sent from the PostgreSQL - general mailing list archive at Nabble.com.



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: invalid byte sequence for encoding "UTF8": 0x00
@ 2011-11-20 10:19  hubert depesz lubaczewski <depesz@depesz.com>
  parent: pawel_kukawski <kukismen@gmail.com>
  0 siblings, 0 replies; 18+ messages in thread

From: hubert depesz lubaczewski @ 2011-11-20 10:19 UTC (permalink / raw)
  To: pawel_kukawski <kukismen@gmail.com>; +Cc: pgsql-general

On Sat, Nov 19, 2011 at 09:32:12AM -0800, pawel_kukawski wrote:
> Is there any way I can store NULL character (\u0000) in string ?
> 
> Or there is only one option that I have change every text field to bytea.

correct question is: why do you want to store \u0000 in text field?

Best regards,

depesz

-- 
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* invalid byte sequence for encoding "UTF8": 0xff
@ 2018-04-26 19:31  Kris Olson <Kris.Olson@dri.edu>
  0 siblings, 0 replies; 18+ messages in thread

From: Kris Olson @ 2018-04-26 19:31 UTC (permalink / raw)
  To: pgsql-general

I just did this on all my import dump files:

perl -p -i -e 's/\xff//g' *.dump

Kris

PUBLIC RECORDS NOTICE: In accordance with NRS Chapter 239, this email and responses, unless otherwise made confidential by law, may be subject to the Nevada Public Records laws and may be disclosed to the public upon request.

^ permalink  raw  reply  [nested|flat] 18+ messages in thread


end of thread, other threads:[~2018-04-26 19:31 UTC | newest]

Thread overview: 18+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-09-03 08:06 invalid byte sequence for encoding "UTF8": 0xff Ashish Karalkar <ashish.karalkar@info-spectrum.com>
2007-09-03 08:15 ` Martijn van Oosterhout <kleptog@svana.org>
2007-09-03 08:42 ` Albe Laurenz <all@adv.magwien.gv.at>
2007-09-03 10:47 Re: invalid byte sequence for encoding "UTF8": 0xff Ashish Karalkar <ashish.karalkar@info-spectrum.com>
2007-09-03 11:24 ` Albe Laurenz <all@adv.magwien.gv.at>
2007-09-03 12:10   ` Ashish Karalkar <ashish.karalkar@info-spectrum.com>
2011-05-11 07:16 invalid byte sequence for encoding "UTF8": 0xf1612220 AI Rumman <rummandba@gmail.com>
2011-05-12 02:52 ` Re: invalid byte sequence for encoding "UTF8": 0xf1612220 Craig Ringer <craig@postnewspapers.com.au>
2011-05-12 08:32   ` Re: invalid byte sequence for encoding "UTF8": 0xf1612220 Cédric Villemain <cedric.villemain.debian@gmail.com>
2011-06-15 20:18 Invalid byte sequence for encoding "UTF8": 0xedbebf BRUSSER Michael <Michael.BRUSSER@3ds.com>
2011-06-15 21:37 ` Re: Invalid byte sequence for encoding "UTF8": 0xedbebf Alan Hodgson <ahodgson@simkin.ca>
2011-06-15 21:44   ` Re: Invalid byte sequence for encoding "UTF8": 0xedbebf BRUSSER Michael <Michael.BRUSSER@3ds.com>
2011-06-16 09:15 ` Re: Invalid byte sequence for encoding "UTF8": 0xedbebf Albe Laurenz <laurenz.albe@wien.gv.at>
2011-06-16 17:32   ` Re: Invalid byte sequence for encoding "UTF8": 0xedbebf BRUSSER Michael <Michael.BRUSSER@3ds.com>
2011-06-17 07:58     ` Re: Invalid byte sequence for encoding "UTF8": 0xedbebf Albe Laurenz <laurenz.albe@wien.gv.at>
2011-11-19 17:32 invalid byte sequence for encoding "UTF8": 0x00 pawel_kukawski <kukismen@gmail.com>
2011-11-20 10:19 ` Re: invalid byte sequence for encoding "UTF8": 0x00 hubert depesz lubaczewski <depesz@depesz.com>
2018-04-26 19:31 invalid byte sequence for encoding "UTF8": 0xff Kris Olson <Kris.Olson@dri.edu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox