Let's try mozilla's fixedCharAt function
This commit is contained in:
parent
81fd5b5c9b
commit
e0b3279cc1
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user