SledgehammerPL SledgehammerPL - 9 months ago 64
Ajax Question

Sending UTF-encoded POST request

Possible Duplicate:

‘ascii’ codec can’t decode byte (problem when using django)

From a Chrome extension, I try to send a POST request:

var = encodeURIComponent(somevariable);

var parameters = "var=" + var;"POST", "django/page/", true);
mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

and when in
, there are some UTF-chars, it breaks with

'ascii' codec can't decode byte 0xc4 in position 14: ordinal not in

In Django I have:

some_var = form.cleaned_data['var'].replace('\n','')

The result is wrong because the
contains wrong chars:

some_var = u"blah blah blah z\u0142o\u017a"

Of course, it should be
u"blah blah blah złoź"
, but I really don't know where and how I should change the encoding.

Update after closure:

This question isn't duplicate - the problem isn't in the message. I googled more than you think you can.

The most important thing (which I don't understand) is the difference between

u"ł" and u"\u0142" and "\u0142"

all of those means almost the same, but not the same.


Should you be complaining about Unicode if you don't actually use it?

some_var = form.cleaned_data['var'].replace(u'\n', u'')