Re: about encoding - Mailing list pgsql-admin

From Steve Crawford
Subject Re: about encoding
Date
Msg-id 4F79CBEC.7080805@pinpointresearch.com
Whole thread Raw
In response to about encoding  (superman0920 <superman0920@gmail.com>)
List pgsql-admin
On 03/28/2012 08:00 PM, superman0920 wrote:
BLOCKQUOTE {MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em } OL {MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px } UL {MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px } P {MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px } BODY {LINE-HEIGHT: 1.5; FONT-FAMILY: 微软雅黑; COLOR: #000000; FONT-SIZE: 10.5pt }
hello
i want to insert a report to postgresql,the report contain something Chinese characters and the postgresql is utf-8.
the response from db is this:
ERROR:  invalid byte sequence for encoding "UTF8": 0xb1
 
how can i fix it ?
 

<snark>Remove the bad character??</snark>

You need to provide a bit more information, but the likely cause is that the data you are inserting is not UTF8 encoded. Check the system that is generating the data you wish to insert and make sure it is set to write its output as UTF8.

If you cannot set it to write UTF8, then you need to determine what character-set it is using and tell PostgreSQL to use that. See "SET client_encoding..." Note that UTF8 is the character set that PostgreSQL is using internally but you can read and write other sets through the client_encoding setting.

Also be aware that UTF8 is just one of many ways of encoding the various Unicode code-points. People sometimes conversationally interchange Unicode and UTF8 but they are not the same. Make sure that the data you are receiving is specifically UTF8 and not just some unknown Unicode encoding.

If you are still stuck after checking/fixing the above you could actually have bad data in your input or, possibly, an incorrect byte-order issue though that is unlikely in most situations.

Cheers,
Steve

pgsql-admin by date:

Previous
From: Jan Mussler
Date:
Subject: Segmentation fault ( after Shared Lock acquired, same table 4 times )
Next
From: mario martinez hernandez
Date:
Subject: ...