I moved my website from my local test server to NameCheap shared hosting and now I'm running into a problem - some of the pages aren't displaying utf-8 special characters properly (showing question marks instead). All pages are utf-8 encoded, as are all database tables. The strange thing is, some pages display correctly and some don't, in a seemingly random pattern.
For instance, my index page is fine, but my profile page isn't. faq.html works fine, but when I rename it to faq.php it doesn't. And weirdest of all, I have a page with two JQuery tabs where one displays correctly and the other doesn't!
Can someone help me out with this?
The problem is because your file are not with the same encoding. First run the following command in all your files:
In order to fix the problem you have to change all your files to uft-8. You can do it with the command iconv:
Example:
After this you can run file -i fixedx/index.html and you will see that your file is now in uft-8
If you're using PHP and none of the above worked (as it was my case), you need to set the locale with utf-8 encoding.
Like this
This is really annoying problem to fix but you can try these.
First of all, make sure the file is actually saved in UTF-8 format.
Then check that you have
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
in your HTML header.You can also try calling
header('Content-Type: text/html; charset=utf-8');
at the beginning of your PHP script or addingAddDefaultCharset UTF-8
to your .htaccess file.set meta tag in head as
use the link http://www.i18nqa.com/debug/utf8-debug.html to replace the symbols character you want.
then use str_replace like
Its the method i use and help alot. Thanks!
If all the other answers didn't work for you, try disabling HTTP input encoding translation.
This is a setting related to PHP extension mbstring. This was the problem in my case. This setting was enabled by default in my server.
I solve my issue by using utf8_encode();
Hope this help someone.