Facebook charset detection mechanism?

character-encoding, facebook, forms, html, php

Solution

Any idea what this code might be useful for - some kind of server-side client charset detection?

Apparently so.

The Euro sign is useful for charset detection because there are so many ways of encoding it:

- E2 82 AC in UTF-8

- 88 in windows-1251

- 80 in the other windows-125x encodings

- A4 in ISO-8859-7, -15, and -16

- A2 E3 in GB18030

- 85 40 in Shift-JIS

- etc.

As far as I know, browser charset is being transmitted in HTTP request anyway (an "Accept-Charset" header).

It's supposed to transmitted in the HTTP `Content-Type` header, but that doesn't mean that user agents actually get it right.

Problem

Today, I have looked into HTML code of facebook.com, and found something like this: ``` <input type="hidden" value="€,´,€,´,水,Д,Є" name="charset_test"/> ``` It's repeated two times inside the `<form>...</form>`. Any idea what this code might be useful for - some kind of server-side client charset detection? As far as I know, browser charset is being transmitted in HTTP request anyway (an "Accept-Charset" header).

Original source