Page 1 of 1

Special characters display on HTML pages

Posted: 06 May 2011, 15:28
by Jojo_44
Hi,

at first everything works good so far and thank you to grant me access.

I just have a little question about special characters like the German "ä ü ö". If you look to my example file you will see in the first line my zone without converting anything. But the "ü" from "Nürnberg" is the iso encoding i think. This looks very bad so I converted it to utf-8(second line) with the function:

Code: Select all

echo htmlentities($player->path, ENT_QUOTES, 'UTF-8');
http://upload.zero-esports.org/tmwsbeta/player.php

My file encoding is utf-8. Is this the correct way ?

regards, Jojo

Re: special characters

Posted: 06 May 2011, 15:40
by gouxim
All the request and response bodies are indeed UTF-8.

If you declare your HTML page as a UTF-8 (with the meta tag below, in the <head>) page you should be able to display them without using html-entities I think:

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
The reason is even if your file is UTF-8, the client browser won't known that, and if you don't specify the encoding with a meta tag or a response header, it will often assume it is latin1.

You can check at http://home.trackmania.com/overview/ : the path is displayed as is, without htmlentities. Is it displayed okay?

PS: I edited the topic title

Re: Special characters display on HTML pages

Posted: 06 May 2011, 16:10
by Jojo_44
Ok it works. My editor set the file encoding automatically to utf-8 but during the upload my ftp client set it to latin. So I was very confused ;) The meta tag solves the problem.

I am continue testing.

Nice weekend,

Jojo

Re: Special characters display on HTML pages

Posted: 06 May 2011, 16:14
by gouxim
In any case the file encoding doesn't really matter. When the client browser get the file, there's no way of telling whether the file is utf8 or latin simply because there's no file header sor something like that (there's "UTF-8 with BOM" which adds a special char at the begining of the file, but you should not use that) .

This is why we use meta tags to tell what the encoding is :ugeek: