v9.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.default = (buf, start, length) => {
  4. let offset = start;
  5. const end = offset + length;
  6. const codes = [];
  7. while (offset < end) {
  8. const octet1 = buf[offset++];
  9. if ((octet1 & 0x80) === 0) {
  10. codes.push(octet1);
  11. continue;
  12. }
  13. const octet2 = buf[offset++] & 0x3f;
  14. if ((octet1 & 0xe0) === 0xc0) {
  15. codes.push(((octet1 & 0x1f) << 6) | octet2);
  16. continue;
  17. }
  18. const octet3 = buf[offset++] & 0x3f;
  19. if ((octet1 & 0xf0) === 0xe0) {
  20. codes.push(((octet1 & 0x1f) << 12) | (octet2 << 6) | octet3);
  21. continue;
  22. }
  23. if ((octet1 & 0xf8) === 0xf0) {
  24. const octet4 = buf[offset++] & 0x3f;
  25. let unit = ((octet1 & 0x07) << 0x12) | (octet2 << 0x0c) | (octet3 << 0x06) | octet4;
  26. if (unit > 0xffff) {
  27. unit -= 0x10000;
  28. codes.push(((unit >>> 10) & 0x3ff) | 0xd800);
  29. unit = 0xdc00 | (unit & 0x3ff);
  30. }
  31. codes.push(unit);
  32. }
  33. else {
  34. codes.push(octet1);
  35. }
  36. }
  37. return String.fromCharCode(...codes);
  38. };
  39. //# sourceMappingURL=v9.js.map