Re: PHP + PostgreSQL: invalid byte sequence for encoding "UTF8"
| From: | Niel | Date: | Sat, 21 Jul 2007 15:04:25 +0000 |
| Subject: | Re: PHP + PostgreSQL: invalid byte sequence for encoding "UTF8" | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-43833@lists.php.net to get a copy of this message | ||
Hi
Please configure your email client so we don't receive 5 copies of your
mail.
> I already did this and all encoding settings are right, but I figured out something more.
>
> 1) Using pg_query for fetching UTF8 data from database is working properly. Of course when I
> try to output it direclty then I get something like that as output "lacarrière" - but
> when I use utf8_decode() on the UTF8-bytes I get it the right way "lacarrière".
This indicates that PHP not using UTF-8. That output is typical of
UTF-8 output as Latin characters.
> 2) I found another PHP application which is able to insert UTF8 data properly, phpPgAdmin, but
> it seems that it uses the ADODB-Layers for executing SQL-statements.
> Well, the fact that phpPgAdmin runs on the same machine handling properly UTF8 data means that
> my PHP is well configurated handling UTF8.
Not true, it only indicates that phpPgAdmin is is configured to handle
UTF-8 correctly.
> 3) When I add to my DB-Class utf8_encode() on the querystring I send to the database, it works
> properly, the insert is fine, so that's a temporary solution for my first problem.
> 4) When I get data from database I usually would have to do a utf8_decode on EVERY string which
> is fetched from database. So my solution is now, to handle all strings comming UTF8 from database as
> they are comming with UTF8-bytes, and really only then when I need to decode them I decode them for
> further use.
Once again indicating your data needs to be converted from some other
character set.
I had similar problems getting PHP to work with UTF-8 and MySQL. Many
of PHP's function are not multibyte aware and assume a Latin character set.
What, if any, output buffering are you using? What is your
default_charset set to?
--
Niel Archer