[Greasemonkey] Javascript character encoding problem

Jonas Lundberg my.name.is.hans at gmail.com
Thu Apr 6 07:58:24 EDT 2006


Hello,
no that does not work. It seems that although the page headers can say
something about the encoding, they do not affect the actual encoding
of the message.

I noticed that a normal submit (using a submit button) on some pages
sends the characters scrambled, and on other pages as they should be.
Thus, using a normal submit, the character encoding depends on the
page encoding.

Now, how do I set the actual encoding of what I send through 
GM_xmlhttpRequest? Is that at all possible?

Regards
Hans


This is my send function again:

    function send(data)             {
    GM_xmlhttpRequest({
    method: 'POST',
    url: mysubmit,
    headers: {
        'Content-type': 'multipart/form-data; boundary=shapecms; charset=utf-8',
    },
    data: data,
    onload: function(responseDetails) {
            var ok = '200';
            if(responseDetails.status == ok) {
            }
    //       GM_log(responseDetails.responseText);
    }
}) };

Regards
Hans

On 4/6/06, Lenny Domnitser <ldrhcp at gmail.com> wrote:
> On 4/5/06, Jonas Lundberg <my.name.is.hans at gmail.com> wrote:
> > That's possible, but I am trying to send some Swedish characters, the
> > A and o with a ring and dots( å and ä and ö, also Å Ä Ö). If I submit
> > these using a traditional submit button, then they are send as they
> > are. If I use GM_xmlhttpreques, then OTHER characters are sent. These
> > other characters might be UTF-8, but my problem is that they are
> > DIFFERENT from the ones that were in my form.
> > Maybe, I am doing something wrong here?
>
> Try appending a charset parameter to your Content-Type header. Untested remedy:
>
> Replace
>  headers: { 'Content-type': 'multipart/form-data; boundary=shapecms' }
> with
>  headers: { 'Content-type': 'multipart/form-data;
> boundary=shapecms; charset=utf-8' }
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>


More information about the Greasemonkey mailing list