Spaces:
Running
Running
File size: 448 Bytes
c2b7eb3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | export function ucs2length(s) {
let result = 0;
let length = s.length;
let index = 0;
let charCode;
while (index < length) {
result++;
charCode = s.charCodeAt(index++);
if (charCode >= 0xd800 && charCode <= 0xdbff && index < length) {
charCode = s.charCodeAt(index);
if ((charCode & 0xfc00) == 0xdc00) {
index++;
}
}
}
return result;
}
|