jQuery.ajax()
is doing something weird when escaping my data.
For example, if I send the request:
$.ajax({
url: 'somethinguninteresting',
data: {
name: 'Ihave¬aweirdcharacter';
}
});
then investigate the XHR in Chrome devtools, it shows the "Request Payload" as name=Ihave%C2%ACaweirdcharacter
Now, I've figured out that:
'¬'.charCodeAt(0) === 172
and that 172 is AC
in hexadecimal.
Working backwards, C2
(the "extra" character being prepended) in hexadecimal is 194 in decimal, and
String.fromCharCode(194) === 'Â'
My Question:
Why does
encodeURIComponent('¬')
return '%C2%AC'
, which would appear to be the result of calling
encodeURIComponent('¬')
(which itself returns '%C3%82%C2%AC'
)?