v5.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.default = (uint8, start, length) => {
  4. const end = start + length;
  5. let x = start;
  6. let str = '';
  7. while (x < end) {
  8. const b1 = uint8[x++];
  9. if ((b1 & 0x80) === 0) {
  10. str += String.fromCharCode(b1);
  11. }
  12. else if ((b1 & 0xe0) === 0xc0) {
  13. str += String.fromCharCode(((b1 & 0x1f) << 6) | (uint8[x++] & 0x3f));
  14. }
  15. else if ((b1 & 0xf0) === 0xe0) {
  16. str += String.fromCharCode(((b1 & 0x1f) << 12) | ((uint8[x++] & 0x3f) << 6) | (uint8[x++] & 0x3f));
  17. }
  18. else if ((b1 & 0xf8) === 0xf0) {
  19. const b2 = uint8[x++] & 0x3f;
  20. const b3 = uint8[x++] & 0x3f;
  21. const b4 = uint8[x++] & 0x3f;
  22. let code = ((b1 & 0x07) << 0x12) | (b2 << 0x0c) | (b3 << 0x06) | b4;
  23. if (code > 0xffff) {
  24. code -= 0x10000;
  25. str += String.fromCharCode(((code >>> 10) & 0x3ff) | 0xd800);
  26. code = 0xdc00 | (code & 0x3ff);
  27. }
  28. str += String.fromCharCode(code);
  29. }
  30. else {
  31. str += String.fromCharCode(b1);
  32. }
  33. }
  34. return str;
  35. };
  36. //# sourceMappingURL=v5.js.map