/** * Checks whether a given String consists only of surrogate pairs. * @param word to be checked * @since 4.2 */ protected boolean isSurrogatePairCombination (String word) { if (word.length() > 1 && word.length() % 2 == 0 && word.codePointCount(0, word.length()) != word.length()) { // some symbols such as emojis (😂) have a string length that equals 2 boolean isSurrogatePairCombination = true; for (int i = 0; i < word.length() && isSurrogatePairCombination; i += 2) { isSurrogatePairCombination &= Character.isSurrogatePair(word.charAt(i), word.charAt(i + 1)); } return isSurrogatePairCombination; } return false; }
public int codePointAt(int strIndex, CharSequence testString, int rightBound) { /* * We store information about number of codepoints we read at variable * readCharsForCodePoint. */ int curChar; readCharsForCodePoint = 1; if (strIndex < rightBound - 1) { char high = testString.charAt(strIndex++); char low = testString.charAt(strIndex); if (Character.isSurrogatePair(high, low)) { char[] curCodePointUTF16 = new char[] { high, low }; curChar = Character.codePointAt(curCodePointUTF16, 0); readCharsForCodePoint = 2; } else { curChar = high; } } else { curChar = testString.charAt(strIndex); } return curChar; }
if (isSurrogatePair(high, low)) { return toCodePoint(high, low);
if (isSurrogatePair(high, low)) { return toCodePoint(high, low);
if (isSurrogatePair(high, low)) { return toCodePoint(high, low);
if (isSurrogatePair(high, low)) { return toCodePoint(high, low);
if (isSurrogatePair(high, low)) { return toCodePoint(high, low);
if (isSurrogatePair(high, low)) { return toCodePoint(high, low);
@Override public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) { int strLength = matchResult.getRightBound(); if (stringIndex + 1 > strLength) { matchResult.hitEnd = true; return -1; } char high = testString.charAt(stringIndex); if (Character.isHighSurrogate(high) && (stringIndex + 2 <= strLength)) { char low = testString.charAt(stringIndex + 1); if (Character.isSurrogatePair(high, low)) { return next.matches(stringIndex + 2, testString, matchResult); } } return next.matches(stringIndex + 1, testString, matchResult); }
|| !Character.isSurrogatePair(c, (low = in.charAt(++i)))) { throw new UnpairedSurrogateException((i - 1), utf16Length); || !Character.isSurrogatePair(c, in.charAt(i + 1)))) { throw new UnpairedSurrogateException(i, utf16Length);
if (inIx + 1 == inLength || !isSurrogatePair(c, (low = in.charAt(++inIx)))) { throw new UnpairedSurrogateException(inIx, inLength);
@Override public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) { int strLength = matchResult.getRightBound(); if (stringIndex + 1 > strLength) { matchResult.hitEnd = true; return -1; } char high = testString.charAt(stringIndex); if (Character.isHighSurrogate(high) && (stringIndex + 2 <= strLength)) { char low = testString.charAt(stringIndex + 1); if (Character.isSurrogatePair(high, low)) { return lt.isLineTerminator(Character.toCodePoint(high, low)) ? -1 : next.matches(stringIndex + 2, testString, matchResult); } } return lt.isLineTerminator(high) ? -1 : next.matches(stringIndex + 1, testString, matchResult); }
@Override public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) { int strLength = matchResult.getRightBound(); int offset = -1; if (stringIndex < strLength) { char high = testString.charAt(stringIndex++); if (contains(high)) { offset = next.matches(stringIndex, testString, matchResult); if (offset > 0) { return offset; } } if (stringIndex < strLength) { char low = testString.charAt(stringIndex++); if (Character.isSurrogatePair(high, low) && contains(Character.toCodePoint(high, low))) { return next.matches(stringIndex, testString, matchResult); } } } return -1; }
if (inIx + 1 == inLimit || !isSurrogatePair(c, (low = in.charAt(++inIx)))) { throw new IllegalArgumentException("Unpaired surrogate at index " + (inIx - 1) + " of " + inLimit); } else { if ((MIN_SURROGATE <= c && c <= MAX_SURROGATE) && (inIx + 1 == inLimit || !isSurrogatePair(c, in.charAt(inIx + 1)))) {
if (inIx + 1 == inLimit || !isSurrogatePair(c, (low = in.charAt(++inIx)))) { throw new IllegalArgumentException("Unpaired surrogate at index " + (inIx - 1) + " of " + inLimit); } else { if ((MIN_SURROGATE <= c && c <= MAX_SURROGATE) && (inIx + 1 == inLimit || !isSurrogatePair(c, in.charAt(inIx + 1)))) {
if (inIx + 1 == inLimit || !isSurrogatePair(c, (low = in.charAt(++inIx)))) { throw new IllegalArgumentException("Unpaired surrogate at index " + (inIx - 1) + " of " + inLimit); } else { if ((MIN_SURROGATE <= c && c <= MAX_SURROGATE) && (inIx + 1 == inLimit || !isSurrogatePair(c, in.charAt(inIx + 1)))) {
if (inIx + 1 == inLimit || !isSurrogatePair(c, (low = in.charAt(++inIx)))) { throw new IllegalArgumentException("Unpaired surrogate at index " + (inIx - 1) + " of " + inLimit); } else { if ((MIN_SURROGATE <= c && c <= MAX_SURROGATE) && (inIx + 1 == inLimit || !isSurrogatePair(c, in.charAt(inIx + 1)))) {
if (inIx + 1 == inLimit || !isSurrogatePair(c, (low = in.charAt(++inIx)))) { throw new UnpairedSurrogateException((inIx - 1), inLimit); } else { if ((MIN_SURROGATE <= c && c <= MAX_SURROGATE) && (inIx + 1 == inLimit || !isSurrogatePair(c, in.charAt(inIx + 1)))) {
if (inIx + 1 == inLimit || !isSurrogatePair(c, (low = in.charAt(++inIx)))) { throw new UnpairedSurrogateException((inIx - 1), inLimit); } else { if ((MIN_SURROGATE <= c && c <= MAX_SURROGATE) && (inIx + 1 == inLimit || !isSurrogatePair(c, in.charAt(inIx + 1)))) {
final char endHigh = buffer[end - 1]; final boolean surAtFront = allowFrontSur && Character.isSurrogatePair(frontHigh, frontLow); if (surAtFront && (len < 3)) { && Character.isSurrogatePair(endHigh, endLow); allowFrontSur = allowEndSur = true; if (surAtFront == surAtEnd) {