utf-16 surrogate pairs

Symbols outside BMP (charcode >= 0x10000) are represented in UTF-16 as surrogate pairs (see wiki about UTF-16) and should be encoded and decoded properly.

var str = "\uD834\uDD1E"; // MUSICAL SYMBOL G CLEF
console.log(decodeURIComponent(escape(utf8_encode(str))) == str);
var str = "\xF0\x9D\x84\x9E"; // the same, but utf8-encoded;
console.log(unescape(encodeURIComponent(utf8_decode(str))) == str);