utf-8 special characters not displaying
It sounds like that if you request faq.html
the webserver signals your browser that the file is in UTF-8 encoding.
Check that with your browser which encoding is announced and used, please see the documentation of your browser how to do that. Every browser has this, most often accessible via the menu (to specify your preference which website's encoding should be used) and to see what the server returned, you often find this in page properties.
Then it sounds like that if you request faq.php
the webserver singals your browser that the file is in some other encoding. Probably no charset/encoding is given as per default PHP configuration setting. As it's a PHP file you can most often solve this by changing the PHP configuration default_charset
Docs directive:
default_charset = "UTF-8"
Locate your php.ini on the host and edit it accordingly.
If you don't have the php.ini available, you can change this by code as well by using the ini_set
Docs function:
ini_set('default_charset', 'UTF-8');
Take care that you change this very early in your script because PHP needs to be able to send out headers to have this working, and headers can't be set any longer if they have already been send.
Manually sending the Content-Type
header-line does work, too:
header('Content-Type: text/html; charset=UTF-8');
Additionally it's good practice that all the HTML pages you output have this header as well in their HTML <head>
section:
<html>
<head>
...
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
...
Hope this is helpful.
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 adding AddDefaultCharset UTF-8
to your .htaccess file.