views:

93

answers:

1

From time time to time my PostgreSQL DB is reporting a strange error:


[client] postgres7 error: [-1: ERROR: invalid byte sequence for encoding \"UTF8\": 0xb4 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\".] in adodb_throw(INSERT INTO page_comments(pageid, pagetype, sender_name, sender_mail, sender_url, comment, owner_uid, owner_gid, sortorder, level, parent) VALUES( 1493, 102, \'alexis\', \'[email protected]\', \'\', \'

Next friday i´ll visit Barcelona so in case you need one of this mugs please let me know.

\', 1000, 1000, 1, 1, NULL ), )


Now, I see that it is coming from the funny apostrophe sign. Yet I am totally confused, as the DB was initialized in UTF8, the web application is serving UTF8 pages, and, moreover, the content is being even utf8_encoded before it is pushed into the database.

Does anybody know how to avoid this error?

+2  A: 

U+00B4, ACUTE ACCENT, is encoded as '\xb4' in ISO-8859-1. In UTF-8, it would be '\xc2\xb4'. So some part of your application changes the encoding to Latin-1. Find and fix that place, and the error should go away.

Martin v. Löwis
thanks! I just figured out that ajax requests were not encoded properly by javascript, thus _some_ symbols got screwed up.
clops