0

I have a problem with my HTML5 webpage that I haven't been able to research an answer for. Im using swedish letters in the text (åäö) and started out by using UTF-8 encodig as such:

<!DOCTYPE html>
<html lang = 'sv'>

<head>
    <title> </title>
    <meta charset='utf-8'>
    <meta name="description" content=' '>
    <link rel = 'stylesheet' href = './css/auroracss.css'>
</head>

This doesn't work for displaying the swedish letters in 3 out of 4 of my HTML5 pages, as I get the � chars when I preview. However, for the fourth page, using exactly the same head tag, the characters are displayed properly.

When I switch out UTF-8 to ISO-8859-1 the opposite is true - displaying the characters will work fine for 3 out of 4 pages but the same one which displayed properly with UTF-8 will show � chars when the ISO enconding is applied.

Everything validates.

I would like to stick to only one encoding choice here and not mix them even though that may be a quick fix. What is the cause for the problem?

  • 3
    This simply means the physical file is not encoded in the encoding that you specify in the header. – deceze Dec 30 '13 at 12:42

1 Answers1

4

The 3 out of 4 pages are, in fact, ISO-8859-1 encoded (or maybe windows-1252). Assuming that the server does not announce character encoding in HTTP headers (as it seems, since your meta tag takes effect), you simply need to a) declare <meta charset=windows-1252> for them instead of claiming them to be UTF-8 encoded, or b) convert them to UTF-8 encoded.

The conversion, which is generally preferable (UTF-8 is widely regarded as the way to go, even declared as the only allowed encoding in some “living standards”). You can use e.g. Notepad++; using it, you simply open a file, use the program command to convert to UTF-8, and save the file.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
  • Thank you for taking the time to answer. I dont have enough rep to upvote your reply but it was of big help. – Cookiemonster Jan 09 '14 at 13:47
  • When an answer is correct, you can upvote it, but you have to indicate that it is correct by clicking the check mark on the left side of the answer – Brian Dillingham Sep 09 '14 at 20:03