source: trip-planner-front/node_modules/ajv/lib/runtime/ucs2length.ts@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 629 bytes
Line 
1// https://mathiasbynens.be/notes/javascript-encoding
2// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
3export default function ucs2length(str: string): number {
4 const len = str.length
5 let length = 0
6 let pos = 0
7 let value: number
8 while (pos < len) {
9 length++
10 value = str.charCodeAt(pos++)
11 if (value >= 0xd800 && value <= 0xdbff && pos < len) {
12 // high surrogate, and there is a next character
13 value = str.charCodeAt(pos)
14 if ((value & 0xfc00) === 0xdc00) pos++ // low surrogate
15 }
16 }
17 return length
18}
19
20ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default'
Note: See TracBrowser for help on using the repository browser.