[Greasemonkey] Javascript character encoding problem

Anton Berezin tobez at tobez.org
Wed Apr 5 10:22:04 EDT 2006


On Wed, Apr 05, 2006 at 12:23:30AM +0200, Jonas Lundberg wrote:
> Although this must be a common question, I have not found a good answer to it.
> 
> I am posting a form through GM_xmlhttpRequest:
> 
> GM_xmlhttpRequest({
>     headers: {
>         'Content-type': 'multipart/form-data; boundary=shapecms',
>     },
>     data: data,
> 
> However, Swedish characters in the "data" variable, are scrambled.

> -----------------------------41184676334
> Content-Disposition: form-data; name="titel"
> 
> ~AP~AP
> -----------------------------41184676334

I had success with UTF-8 in GM_xmlhttpRequest(), but I was using

   'Content-type': 'application/x-www-form-urlencoded'

- with the POST request - and was doing encodeURIComponent() for stuff
inside the data.  Then again, the backend expected data to be in UTF-8.

Failing that, you might want to experiment with different values of
the Transfer-Encoding header.

\Anton.
-- 
An undefined problem has an infinite number of solutions.
-- Robert A. Humphrey


More information about the Greasemonkey mailing list