Created
March 30, 2017 17:46
-
-
Save bhamiltoncx/9282e943efab384220723a0daa37d72e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class CodePointCounter { | |
private final String input; | |
public int inputIndex = 0; | |
public int codePointIndex = 0; | |
public int advanceToIndex(int newCodePointIndex) { | |
assert newCodePointIndex >= codePointIndex; | |
while (codePointIndex < newCodePointOffset) { | |
int codePoint = Character.codePointAt(input, inputIndex); | |
inputIndex += Character.charCount(codePoint); | |
codePointIndex++; | |
} | |
return inputIndex; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment