views:

2012

answers:

5

My pages contain German characters and I have typed the text in between the HTML tag, but the browser views some characters differently. Do I need to include anything in HTML to properly display German characters?

<label> ausgefüllt </label>
+1  A: 

Sounds like a character encoding issue, in that the file is saved as a different character encoding to what the webserver is saying it is.

Rowland Shaw
+8  A: 

UTF8 is your friend.

Try

<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">

and check which encoding your webserver sends in the header.

edit:

If you use PHP, you can send your own headers in this way (you have to put this before any other output):

<?php header('Content-Type: text/html; charset=utf-8'); ?>

Also doublecheck that you saved your document in UTF8.

Karsten
I have already added in My head tag,Still i got the hidden character
venkatachalam
then your document is probably not in fact saved in UTF-8
Michael Borgwardt
You need the proper header to be sent from the webserver. The META tag won't be enough
Gareth
Explanation: originally, it was intended that the webserver would parse the file and set its headers according to the <META HTTP-EQUIV="..."> tags, but webservers generally don't, and it's not specified how the browser should behave if they disagree.
Michael Borgwardt
@brazzy: it is specified in detail: http://www.w3.org/TR/REC-html40/charset.html#spec-char-encoding and there are a few FAQ/QA articles on W3C website about this.
porneL
+4  A: 

Have you tried &uuml; (ü) and &Uuml; (Ü)?

You can find how to type other letters here.

petsson
that's massively impractical given how common these are going to be, he shouldn't and doesn't have to encode like this
annakata
Maybe, but this is how code my homepages with Swedish characters.
petsson
It's a workaround, but fortunately no longer necessary, if you specify the correct encoding. Sorry for the downvote, but there are much better solutions around.
Joachim Sauer
Actually, I didn't know that. I guess I'm one of those who brazzy is reffering to two posts below. :/
petsson
+29  A: 

It seems you need some basic explanations about something that unfortunately even most programmers don't understand properly.

Files like your HTML page are saved and transmitted over the internet as a sequence of bytes, but you want them displayed as characters. In order to translate bytes into characters, you need a set of rules called a character encoding. Unfortunately, there are many different character encodings that have historically emerged to handle different languages. Most of them are based on the American ASCII encoding, but as soon as you have characters outside of ASCII such as German umlauts, you need to be very careful about which encoding you use.

The source of your problem is that in order to correctly decode an HTML file, the browser needs to know which encoding to use. You can tell it so in several ways:

So what you need to do is to pick one encoding, save the HTML file using that encoding, and make sure that you declare that encoding in at least one of the ways listed above (and if you use more than one make damn sure they agree). As for what encoding to use, Germans usually use ISO-8859-15, but UTF-8 is a good alternative that can handle any kind of non-ASCII characters at the same time.

Michael Borgwardt
+1 you should bold "save the HTML file using that encoding, and makesure that you declare thet encoding in at least one of the ways listed above". Its funny how many people just declare UTF-8 without saving it as UTF-8...
You should alter the order: 1. HTTP header field, 2. XML declaration, 3. HTML META element. See http://www.w3.org/TR/html401/charset.html#h-5.2.2 and http://www.w3.org/TR/xml/#charencoding
Gumbo
+2  A: 

I don't like the use of HTML entities (like %uuml;), they are only needed when there is something wrong with your characterset.

In short:

The RIGHT way is to fix your characterset.

The EASY way is to just use entities. You may not ever see any problems with this.

Tracking down characterset error can be very difficult. If you give us an URL where we can see the problem, we can probably give you a good hint where to look.

myplacedk