Let's try mozilla's fixedCharAt function
This commit is contained in:
parent
5cf9dab550
commit
1adcc069df
@ -213,15 +213,18 @@ function design4(input) {
|
||||
const surrogatePairs = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
||||
var charIterateState;
|
||||
function charIterate(input) {
|
||||
let stringLength = (input.length - 1);
|
||||
for (let i = 0; i < stringLength; ++i) {
|
||||
if (surrogatePairs.exec(input.charCodeAt(charIterateState)) !== null) {
|
||||
stringLength--;
|
||||
}
|
||||
}
|
||||
if (charIterateState == undefined) {
|
||||
console.log("undefined! setting to zero");
|
||||
charIterateState = 0;
|
||||
} else {
|
||||
if (charIterateState < (input.length - 1)) {
|
||||
if (charIterateState < stringLength) {
|
||||
charIterateState++;
|
||||
if (surrogatePairs.exec(input.charCodeAt(charIterateState)) !== null) {
|
||||
//charIterateState++;
|
||||
}
|
||||
} else {
|
||||
charIterateState = 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user