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('');
|
let temp = input.split('');
|
||||||
for (let i = 0; i < stringLength; ++i) {
|
for (let i = 0; i < stringLength; ++i) {
|
||||||
let compareString = temp.join("");
|
let compareString = temp.join("");
|
||||||
console.log(surrogatePairs.exec(compareString), compareString);
|
//console.log(surrogatePairs.exec(compareString), compareString);
|
||||||
let stringEvalIndex = surrogatePairs.exec(compareString).index;
|
let stringEval = undefined, stringEvalIndex = undefined;
|
||||||
if (stringEvalIndex != null && stringEvalIndex == i) {
|
try {
|
||||||
stringLength--;
|
while ((stringEval = surrogatePairs.exec(compareString)) !== null) {
|
||||||
console.log("Decreasing stringLength variable to", stringLength);
|
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) {
|
if (charIterateState == undefined) {
|
||||||
console.log("undefined! setting to zero");
|
console.log("undefined! setting to zero");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user