Answer the question
In order to leave comments, you need to log in
How to get rid of Uncaught URIError: URI malformed error?
The goal is to send emoji characters to the server.
All symbols are sent, except for the symbols of the horoscope.
The character itself is 0x2648, whose surrogate pair is ["d7c9", "de48"]
When I try to send the received character using the String.fromCharCode function, I get an error:
How can I solve this problem? Googling didn't bring results.
The send code looks like this:
Uncaught URIError: URI malformed
emoji = '2648';
emoji_symbol = findSurrogatePair('0x'+emoji);
emoji_symbol = String.fromCharCode(parseInt(emoji_symbol[0],16), parseInt(emoji_symbol[1],16));
$.post('/send', {message: emoji_symbol}, function(data) {
console.log(data);
});
function findSurrogatePair(point) {
// assumes point > 0xffff
var offset = point - 0x10000,
lead = 0xd800 + (offset >> 10),
trail = 0xdc00 + (offset & 0x3ff);
return [lead.toString(16), trail.toString(16)];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question