Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
808 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | // https://mathiasbynens.be/notes/javascript-encoding
|
---|
4 | // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
|
---|
5 | function ucs2length(str) {
|
---|
6 | const len = str.length;
|
---|
7 | let length = 0;
|
---|
8 | let pos = 0;
|
---|
9 | let value;
|
---|
10 | while (pos < len) {
|
---|
11 | length++;
|
---|
12 | value = str.charCodeAt(pos++);
|
---|
13 | if (value >= 0xd800 && value <= 0xdbff && pos < len) {
|
---|
14 | // high surrogate, and there is a next character
|
---|
15 | value = str.charCodeAt(pos);
|
---|
16 | if ((value & 0xfc00) === 0xdc00)
|
---|
17 | pos++; // low surrogate
|
---|
18 | }
|
---|
19 | }
|
---|
20 | return length;
|
---|
21 | }
|
---|
22 | exports.default = ucs2length;
|
---|
23 | ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default';
|
---|
24 | //# sourceMappingURL=ucs2length.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.