On 08/05/2009 07:05 AM, Sándor Tamás (HostWare Kft.) wrote:
Hi,
I have a mysql database, which the users can insert comments. As the users can be from different countries, with different character encoding, the mysql table can contain various special characters.
How can I be sure to display these comments properly? I've found the mb_convert_encoding, and for some characters it works okay, but there are some really special characters which displayed as a '?'.
Does anybody know some workarounds?
Thanks,
SanTa
Use UTF-8. Create your database and its tables with UTF-8 char encoding. eg.
ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Note there's no hyphen.
Also, make sure the *data* is converted. You can use iconv for that.
Next, ensure that the browser knows how to display the text. Use either
a header or a meta tag (or both):
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
This is especially important for the page with the comments form.
Any SQL file with your data (for import) should have the following at
the top:
SET NAMES 'utf8';
If you export a dump make sure that line is present before trying to import.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php