I have a Postgresql database in LATIN9 encoding.
I recently migrated my web applications (PHP) from iso_8859_15 (latin9) to UTF8.
So, now, customers are able to specify UTF-8 characters in web forms like comment form or contact form.
I open PG connections in UTF-8 encoding from PHP (PHP function pg_set_client_encoding('UTF8') or so...)
That works well for standard characters like "éàù"... PG is able to convert them from UTF-8 to LATIN9 (the database encoding). But if someone inserts some exotic character like japanese characters "日本語" PostgreSQL throws an error like this:
ERROR: character with byte sequence 0xe6 0x97 0xa5 in encoding "UTF8" has no equivalent in encoding "LATIN9"
I know that I should migrate my database to utf8 to solve this problem, but for some reasons, I can not do that for the moment.
In my case, I'd rather PostgreSQL saves my string removing characters it can not convert or for example replacing them with some symbol like "?" rather than throwing an error...
The only way I figured to make things work like this is to open my connections in LATIN9 and use utf8_decode() PHP function that works like this (replacing unknown characters with "?" symbol)
Is it possible to do it in a better way? Maybe a PG parameter (but I don't see such parameter in postgresql.conf)
Or anyone have another idea on how to handle this?
Thanks,