1

I have recently designed a website that contains German and Dutch characters and I would like the page to use character encoding utf-8.

I have added the xml declaration:

<?xml version="1.0" encoding="UTF-8"?>

and the meta tag:

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

When I viewed the website on-line, the special characters found in the German text were not displaying correctly. When I tried validating the page with the w3c validator, I got the following warning:

The character encoding specified in the HTTP header (iso-8859-1) is different from the value in the XML declaration (utf-8). I will use the value from the HTTP header (iso-8859-1).

Is this a server issue? It's just that I have uploaded the same files to a different server of mine and the pages display correctly there using utf-8.

Any help or advice regarding how I would go about getting the page to encode as utf-8 would be greatly appreciated.

I'm stumped!


Thanks to jason, I found a file named mod_mime-defaults.conf

this file contains the following:

# AddDefaultCharset UTF-8
AddDefaultCharset ISO-8859-1

If I remove the # from before AddDefaultCharset UTF-8, do you think this will help? Or maybe add a # before AddDefaultCharset ISO-8859-1.

I tried editing this file, but I don't think I have permission. Hmmm...?

3
  • You need to do both, comment out the ISO line and remove the # on the UTF-8 line. The # character comments out that line, but you will need permission to edit this file. "AddDefaultCharset ISO-8859-1" means all files served from your web server will default to ISO-8859-1. Commented Jan 5, 2011 at 6:05
  • ok, so it sounds like I definitely need to alter the file named: mod_mime-defaults.conf, so that the AddDefaultCharset ISO-8859-1 is commented out and the AddDefaultCharset UTF-8 is not. I don't seem to have permission to alter this file though. Guess I'll have to try and get the server owner to have a go at this. Hmmm... Commented Jan 5, 2011 at 20:42
  • Depending on server permissions for that user, you may be able to upload an .htaccess file to the website root with the required AddDefaultCharset utf-8 rule. This will override the global server setting. Commented Apr 2, 2013 at 11:11

3 Answers 3

3

This could be a server issue.

If you are using Apache check the Apache config file usually located here /etc/httpd/conf/httpd.conf on a *nix server, for the value of AddDefaultCharset.

This setting specifies the default for all content served. If it is commented out, that means it will rely on the browser's, or META settings to determine the Charset.

Sign up to request clarification or add additional context in comments.

1 Comment

encoding in meta tag should be equal to the server encoding, e.g <meta charset="utf-8" /> and AddDefaultCharset utf-8. utf-8 is hyphenated
0

The HTML meta tag is not the same as the HTTP response header. You need to set the character encoding in the HTTP response header. As per your question history you're using PHP -or are at least familiar with it-, so here's a PHP targeted example of how to do it.

Put the following line in the PHP file before you echo any character.

header('Content-Type: text/html;charset=UTF-8');

See also:


Unrelated to the problem: you shouldn't put a XML declaration on a HTML page. This is recipe for other sort of trouble.

4 Comments

Hmmm... I'm not using any php files here, just .html files. If I remove the xml declaration, I just get the same warning from w3c validator, but just saying "The character encoding specified in the HTTP header (iso-8859-1) is different from the value in the meta declaration (utf-8). I will use the value from the HTTP header (iso-8859-1)". I really need to change the http header to utf-8 if this is possible or make it so that the meta declaration has precedence over the http header. I'm really not too sure what I'm doing here?
@ade123 - as outlined above. It definately sounds like your Apache server setting for AddDefaultCharset, because that setting is designed to override your META settings.
Then you need to configure it in the webserver itself, indeed. Click the 2nd "See also" link to learn more about the difference between the HTTP response header and the HTML meta tag.
@BalusC can you help with this issue stackoverflow.com/questions/20297160/…
-1

I changed charset=UTF-8 to charset=iso-8859-1, and the warning went away.

1 Comment

the solutions provided in the comments of the question are better and more detailed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.