The question, in his opinion, is contradictory: the heading says that the accept-charset parameter does nothing, while the question body says that when the accept-charset attribute is used (this is the correct term) "the headers have another option for accepting charset in the heading request ". I believe the last statement is missing negation.
Browsers send accept-charset parameters to the headers of HTTP requests in accordance with their own principles and settings. For example, my Chrome sends Accept-Charset:windows-1252,utf-8;q=0.7,*;q=0.3 . Such a header is usually ignored by the server-side software, but it can be used (and it was intended to be used) to determine which encoding should be used in the server response in case the server software (form handler, in this case) is capable of use different responses in the response.
The accept-charset attribute in the form element should not affect the headers of HTTP requests, and this is not the case. It is intended to indicate the character encoding that will be used for the form data in the request, and this is what it actually does. The HTML 4.01 specification is unclear about this, but the W3C HTML5 project puts it much better, although for some the odd reason uses the plural: "gives character encodings that should be used for presentation." I believe the reason is that you can specify alternative encodings to prepare for situations where the browser cannot use your preferred encoding. And what actually happens in Chrome, for example, is that if you use accept-charset="foobar utt-8" then UTF-8 is used.
In practice, the attribute is used so that the encoding of the data representation is different from the encoding of the page containing the form. Suppose your page is encoded ISO-8859-1, and someone enters Greek or Hebrew letters into your form. Browsers will need to perform some error recovery, as these characters cannot be represented in ISO-8859-1. (In practice, they turn characters into numeric character links, which is logically wrong, but pragmatic, perhaps the best they can do.) Using <form charset=utf-8> helps here: no matter what the encoding is, form data will be sent as UTF-8, which can handle any character.
If you want to tell the form handler what encoding he should use in his response, you can add a hidden (or not hidden) field in the form for this.
Jukka K. Korpela Oct 11 '12 at 6:15 2012-10-11 06:15
source share