Different language on the site
I am trying to write a website in the Slovak language (central Europe). What I did is put these two meta tags in the title:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta http-equiv="Content-Language" content="sk" />
The problem is that all accented characters are replaced with garbage characters (so I don't work with encoding explicitly). What to do?
Here is the top of the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sk" lang="sk">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Language" content="sk" />
source to share
There are two problems here.
- Tongue
- Character encoding
Tongue
Content-Language The HTTP header describes the natural language of the target audience. It may not be the same as the language in which the document is written. Use the lang attribute to describe this.
Character encoding
This allows you to represent the letters you want to use. You need to make sure that your text is indeed using the encoding of your choice and that the browser is told that this is the encoding you are using.
- Choose a character encoding (UTF-8 is generally the best choice, it covers just about every character you might want to use and saves you to switch encodings for different languages) see http: //www.w3. org / International / tutorials / tutorial-char-enc /
- Make sure the editor preserves this encoding
- Make sure your server indicates that it is using this encoding
- Make sure nothing encodes the encoding between the editor and the server (e.g. inserting into a database that is configured to use a different encoding)
HTTP headers
NB : it is mentioned in your question <meta http-equiv>
. Real HTTP headers are the best place to put this information, and they will override anything your document claims. Make sure your server is configured correctly.
XHTML
XHTML complicates matters ...
- Use xml: lang in addition to lang
- Don't use anything other than UTF-8 . If you do, you must specify it in your XML declaration (and adding an XML declaration will trigger Quirks mode in some browsers).
source to share