Question

I created a php website that would simply load the text from a mysql database, when I open it in a browser the Arabic text is presented in gibberish but then when I change the encoding of my browser to UTF-8 it's displayed properly, how can I force the encoding to be UTF-8 so users don't have to change it?

The menu part of the website which also loads the menu items from the same database (different table, they both have the same coalition "utf8_unicode_ci") but they are all displayed as question marks. How can I fix this?

You can check out the website on test.bdsfilmfest.com

Thank you in advance :)

Was it helpful?

Solution

Your web server probably sends a iso-8859-1 content-type header by default.

Either change the web server's behaviour - it should be possible to do a

 AddDefaultCharset utf-8

in a .htaccess file in the root directory of your web site.

or override the header from within PHP in each individual file:

header("Content-Type: text/html; charset=utf-8");

OTHER TIPS

The most easy way is to set the default_charset somewhere (possibly in apache vhost conf, in php.ini, or .htaccess file), so you won't have to repeat sending correct headers each & every script.

Uncomment this:

<!--<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />!-->
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top