Discussion:
[ADMIN] about encoding
(too old to reply)
superman0920
2012-03-29 03:00:36 UTC
Permalink
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 ?

thx




superman0920
Steve Crawford
2012-04-02 15:55:24 UTC
Permalink
Post by superman0920
hello
i want to insert a report to postgresql£¬the report contain something
Chinese characters and the postgresql is utf-8.
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

Loading...