Having an issue with XMLHttpRequest cutting off the body of a JSON encoded message when Emoji's are used.
var emoji = '"\u2764\uFE0F"';
var data = {
id: messageid, time: new Date(),
layout: { 'type': "message", title: emoji, body: emoji, largeIcon: "http://site/icons/icon.png", foregroundColor: "#445566", backgroundColor: "#222222" },
createNotification: {
layout: { 'type': "genericNotification", title: emoji, subtitle: emoji, largeIcon: "http://site/icons/icon.png" }
}
};
jsonenc = JSON.stringify(data);
console.log(jsonenc) //displays data fine.
var request = new XMLHttpRequest();
request.open('PUT', dict.url, true);
request.setRequestHeader('Content-Type', 'application/json;charset=UTF-16');
request.setRequestHeader('X-User-Token', dict.token);
request.setRequestHeader("Content-length", data.length);
request.send(dict.data);
Upon checking the JSON data in the console, it shows the full length. However, when inspecting the request using mitmproxy, it gets cut off like this:
{"id":"messageid-123456","time":"2015-05-29T03:43:17.566Z","layout":{"type":"message","title":"\"......\"","body":"\"......\"","largeIcon":"http://site/icons/icon.png","foregroundColor":"#445566","backgroundColor":"#222222"},"createNotification":{"layout":{"type":"genericNotification""title":"\"......\"","subtitle":"\"......\"","largeIcon":"http://site/icons/ic