[XHR] Request charset is limited to UTF-8 for x-www-form-urlencoded data

Hi!

In the current spec
(http://www.w3.org/TR/2008/WD-XMLHttpRequest-20080415/) I do not see
the possibility to POST application/x-www-form-urlencoded data with
charset other than UTF-8. I think this is limiting factor, which
should be avoided. UTF-8 is good versatile encoding but it is not
always practical to use it. When developing sites in Russian, for
example, we mainly use windows-1251 encoding, UTF-8 is rarely used as
it doubles network traffic.

The spec says:

> data is a DOMString
> Encode data using UTF-8 for transmission.
> If a Content-Type header is set using setRequestHeader() set the charset parameter of that header to UTF-8.

In my practice application/x-www-form-urlencoded data usually comes
from custom javascript encoding function (as DOMString). When sending
it to server over XHR I use setRequestHeader('Content-type',
'application/x-www-form-urlencoded; charset=windows-1251'). This
informs the server of the correct encoding. This all worked well until
FF3 followed the spec.

I think when the user explicitly sets charset with setRequestHeader()
the browser should not override that. UTF-8 should be used only as
default.

Regards,

Yaroslav Stavnichiy

Received on Monday, 23 June 2008 01:39:06 UTC