Discussion:
[ADMIN] invalid byte sequence for encoding "UTF8": 0xf481 - how could this happen?
(too old to reply)
Rural Hunter
2012-04-14 02:04:48 UTC
Permalink
My db is in utf-8, I have a row in my table say tmp_article and I wanted
to generate ts_vector from the article content:
select to_tsvector(content) from tmp_article;
But I got this error:
ERROR: invalid byte sequence for encoding "UTF8": 0xf481

I am wondering how this could happen. I think if there was invalid UTF8
bytes in the content, it shouldn't have been able to inserted into the
tmp_article table as I sometimes see similar errors when inserting
records to tmp_article. Am I right?
--
Sent via pgsql-admin mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
raghu ram
2012-04-14 02:15:01 UTC
Permalink
Post by Rural Hunter
My db is in utf-8, I have a row in my table say tmp_article and I wanted
select to_tsvector(content) from tmp_article;
ERROR: invalid byte sequence for encoding "UTF8": 0xf481
I am wondering how this could happen. I think if there was invalid UTF8
bytes in the content, it shouldn't have been able to inserted into the
tmp_article table as I sometimes see similar errors when inserting records
to tmp_article. Am I right?
This error can also happen if the byte sequence does not match the
encodingexpected by the server, which is controlled by
"client_encoding".
Try to set client_encoding='LATIN1'

and then execute

select to_tsvector(content) from tmp_article;
--
Thanks & Regards,

Raghu Ram

EnterpriseDB: http://www.enterprisedb.com
raghu ram
2012-04-14 17:38:54 UTC
Permalink
doesn't work either.
db=# show client_encoding;
client_encoding
-----------------
UTF8
(1 row)
db=# set client_encoding='LATIN1';
SET
db=# show client_encoding;
client_encoding
-----------------
LATIN1
(1 row)
db=# select to_tsvector(content) from tmp_article;
ERROR: invalid byte sequence for encoding "UTF8": 0xf481
Try to set client_encoding='SQL_ASCII'

and then execute

select to_tsvector(content) from tmp_article;
--
Thanks & Regards,

Raghu Ram

EnterpriseDB: http://www.enterprisedb.com
Loading...