Let's try mozilla's fixedCharAt function

master
Caleb Fontenot 2023-04-30 22:55:00 +07:00
parent 81fd5b5c9b
commit e0b3279cc1
1 changed files with 18 additions and 6 deletions

@ -217,13 +217,25 @@ function charIterate(input) {
let temp = input.split('');
for (let i = 0; i < stringLength; ++i) {
let compareString = temp.join("");
console.log(surrogatePairs.exec(compareString), compareString);
let stringEvalIndex = surrogatePairs.exec(compareString).index;
if (stringEvalIndex != null && stringEvalIndex == i) {
stringLength--;
console.log("Decreasing stringLength variable to", stringLength);
//console.log(surrogatePairs.exec(compareString), compareString);
let stringEval = undefined, stringEvalIndex = undefined;
try {
while ((stringEval = surrogatePairs.exec(compareString)) !== null) {
stringEvalIndex = stringEval.index;
//console.log("emoji is at index", stringEvalIndex);
}
} catch (e) {
console.log(e);
console.log("Handling exception...");
}
temp.shift();
if (stringEvalIndex == i) {
stringLength--;
temp.splice(i, 1);
//console.log("Decreasing stringLength variable to", stringLength);
}
}
if (charIterateState == undefined) {
console.log("undefined! setting to zero");