code: function decodeSurrogatePairs(str, index) {
  	      if (index < 0 || index >= str.length) {
  	          throw new Error("index=" + index + " is out of range in \"" + str + "\"");
  	      }
  	      var high = str.charCodeAt(index);
  	      var low;
  	      if (high >= 0xd800 && high <= 0xdfff && str.length > index + 1) {
  	          low = str.charCodeAt(index + 1);
  	          if (low >= 0xdc00 && low <= 0xdfff) {
  	              return (high - 0xd800) * 0x400 + low - 0xdc00 + 0x10000;
  	          }
  	      }
  	      return high;
  	  }
docs: see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae