ade123
ade123

Reputation: 2833

Trouble with http header specifying character encoding iso-8859-1 rather than utf-8?

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...?

Upvotes: 1

Views: 12307

Answers (3)

steviebaby59
steviebaby59

Reputation: 1

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

Upvotes: -1

Jason
Jason

Reputation: 393

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.

Upvotes: 3

BalusC
BalusC

Reputation: 1108537

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.

Upvotes: 0

Related Questions