code: function str2rstr_utf8(input) {
      var output = "";
      var i = -1;
      var x, y;
  
      while (++i < input.length) {
          /* Decode utf-16 surrogate pairs */
          x = input.charCodeAt(i);
          y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
          if (0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) {
              x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
              i++;
          }
  
          /* Encode output as utf-8 */
          if (x <= 0x7F)
              output += String.fromCharCode(x);
          else if (x <= 0x7FF)
              output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
                  0x80 | ( x & 0x3F));
          else if (x <= 0xFFFF)
              output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
                  0x80 | ((x >>> 6 ) & 0x3F),
                  0x80 | ( x & 0x3F));
          else if (x <= 0x1FFFFF)
              output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
                  0x80 | ((x >>> 12) & 0x3F),
                  0x80 | ((x >>> 6 ) & 0x3F),
                  0x80 | ( x & 0x3F));
      }
      return output;
  }
docs: /*
  Encode a string as utf-8.
  For efficiency, this assumes the input is valid utf-16.