v17.js 1.5 KB

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