Re: UTF-8 - how does the conversion work?
| From: | Andrei Zmievski | Date: | Tue, 28 Feb 2006 03:29:59 +0000 |
| Subject: | Re: UTF-8 - how does the conversion work? | ||
| References: | 1 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-2444@lists.php.net to get a copy of this message | ||
PHP-GTK will automatically convert strings to UTF-8 when you pass data to it and from UTF-8 when you receive data. The character encoding it uses for conversion is specified as an INI entry php-gtk.codepage. It does not do any detection, it trusts you to set that INI entry properly.
If you have values in the database in iso-8859-14, but code is in utf-8 then you have two options.
1) Do conversion manually. Use iconv() or mbstring_convert_encoding() to convert the database data to UTF-8 encoding and pass the data to PHP-GTK.
2) Set php-gtk.codepage to iso-8859-14 before calling PHP-GTK functions with the database data and reset it back to UTF-8 after you're done. You have to make sure that all the data you pass to PHP-GTK is in the same iso-8859-14 encoding though, so if you mix string literals and database data you may have issues.
-Andrei
On Feb 27, 2006, at 8:20 AM, Christian Weiske wrote:
Hello readers, especiall Andrei, How does the utf8 conversion work? All I know is that it should be done automatically. How does php-gtk detect which charset the data are? Does it try the php code file encoding? What if I have values from database in iso-8859-14, but my code is utf-8? --Regards/MfG, Christian Weiske