v18.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. const points = [];
  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. code = 0xdc00 | (unit & 0x3ff);
  28. points.push(unit0);
  29. }
  30. else {
  31. code = unit;
  32. }
  33. }
  34. }
  35. }
  36. }
  37. points.push(code);
  38. }
  39. return fromCharCode.apply(String, points);
  40. };
  41. //# sourceMappingURL=v18.js.map