Will iso-8859-1 display german umlauts ok or do I

2019-06-25 04:51发布

I have a multi language website that is hosted on a server that appears to have character encoding set to default to iso-8859-1.

I thought I would be best having the pages utf-8 and included a meta tag to declare this. Unfortunately this meta tag seems to get overridden and the page defaults to iso-8859.

Many special characters in the German and Dutch pages are not showing correctly.

Do I need to try and change the server default to utf-8 or something? Maybe I could remove the server default completly? Hmm... really not sure what's best to do here.

Any advice would be great!

3条回答
Rolldiameter
2楼-- · 2019-06-25 05:15

There are several possible solutions, but the cleanest solution would be to properly declare your character encoding.

When serving web pages from an HTTP server, the encoding is normally not given by the meta-tags of the HTML file, but by the Content-type HTTP header.

The webserver is probably sending something like Content-type: text/html; charset=ISO-8859-1, and you need to change that.

How to do this depends on the webserver.

As an addition: Yes, iso-8859-1 is fine for German; it will work for all western European languages. It is missing a few characters, however, notably the Euro sign (that is in iso-8859-15). But using UTF-8 is better, as it covers just about every language.

查看更多
老娘就宠你
3楼-- · 2019-06-25 05:15

You can see the characters supported and the languages that should cover in this Wikipedia article. According to that, German is fully supported and Dutch is almost.

It's not just a matter of selecting the correct character encoding, you also have to save the pages using that encoding. If you save a page as ISO-8859-1 and use a content type that says that it's UTF-8, then it will be decoded incorrectly by the browser. Both ISO-8859-1 and Unicode support the characters you need, but you have to make sure that the content type corresponds to how the pages are actually saved.

查看更多
倾城 Initia
4楼-- · 2019-06-25 05:17

The HTML meta tags for the content type are not used when the HTML page is served over HTTP. Instead, the content type header in the HTTP response will be used. You can determine the content type header with for example Firebug, in the Net panel.

alt text

How to change this depends on the programming language and/or the webserver which you are using, which is unclear from your current question. As per you question history, you seem to be using PHP. In that case, you need to add the following line to the PHP file, before you emit any character to the response.

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

See also:


If you're unable to change the HTTP response header, you have to give more detail about the programming language and webserver which you're using. This way we can give you better suited answers.

If you want to stick to ISO-8859-1, then you need to ensure that your pages are saved as ISO-8859-1 as well instead of as UTF-8. Otherwise some characters may indeed go mojibake when you display a UTF-8 saved resource as ISO-8859-1.

查看更多
登录 后发表回答