PHP 6: Mysql with iso-8859-1 chars outputting utf-8: "Could not convert binary string to Unicode string"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

I have a MySQL database where all tables are in the latin1 character set, with accented (Portuguese) characters.

In my php.ini I have

;;;;;;;;;;;;;;;;;;;;
; Unicode settings ;
;;;;;;;;;;;;;;;;;;;;

unicode.semantics = on
unicode.runtime_encoding = iso-8859-1
unicode.script_encoding = iso-8859-1
unicode.output_encoding = utf-8
unicode.from_error_mode = U_INVALID_SUBSTITUTE
unicode.from_error_subst_char = 3f
unicode.fallback_encoding = iso-8859-1

because all my files and data in mysql server are in iso-8859-1.


When connecting to mysql I issue:

  mysql_query('set names latin1', $this->mysql_link);

but when I do query in any record that have accented characters I get this warning (using mysql_fetch_assoc):

----------
Could not convert binary string to Unicode string (converter UTF-8 failed on bytes (0xE7) at offset 9)
----------

for all accented characters in all fields.


If I changed the set names query to:

  mysql_query('set names utf8', $this->mysql_link);

it works, but I would like to keep compatibility with PHP 5, and for my application it requires set names to be latin1. Also, my databases are not created with the "utf8" option.

As I understood PHP 6's unicode support, all string characters (including mysql result values) are converted from unicode.runtime_encoding to unicode (utf-16), but looks like it is trying to convert from ASCII, which does not have all the accented characters. Am I assuming right? How to make mysql_fetch_assoc assume field values are in iso-8859-1 instead of ASCII?

Thanks,
Rangel Reale

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux