Special characters display on HTML pages

Trackmania Forever public API and its open source PHP SDK.

Moderator: NADEO

Post Reply
User avatar
Jojo_44
Posts: 500
Joined: 12 Jul 2010, 15:58
Location: Germany->Bavaria
Contact:

Special characters display on HTML pages

Post by Jojo_44 » 06 May 2011, 15:28

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
Image
my english sounds very unfriendly but it isn´t ;)

User avatar
gouxim
Nadeo
Nadeo
Posts: 1188
Joined: 14 Jun 2010, 17:20

Re: special characters

Post by gouxim » 06 May 2011, 15:40

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
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)

User avatar
Jojo_44
Posts: 500
Joined: 12 Jul 2010, 15:58
Location: Germany->Bavaria
Contact:

Re: Special characters display on HTML pages

Post by Jojo_44 » 06 May 2011, 16:10

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
Image
my english sounds very unfriendly but it isn´t ;)

User avatar
gouxim
Nadeo
Nadeo
Posts: 1188
Joined: 14 Jun 2010, 17:20

Re: Special characters display on HTML pages

Post by gouxim » 06 May 2011, 16:14

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:
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)

Post Reply

Return to “Trackmania Forever Web Services”

Who is online

Users browsing this forum: No registered users and 3 guests