本文整理了Java中java.lang.Character.isSurrogatePair()
方法的一些代码示例,展示了Character.isSurrogatePair()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Character.isSurrogatePair()
方法的具体详情如下:
包路径:java.lang.Character
类名称:Character
方法名:isSurrogatePair
[英]Indicates whether the specified character pair is a valid surrogate pair.
[中]指示指定的字符对是否为有效的代理项对。
代码示例来源:origin: languagetool-org/languagetool
/**
* 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;
}
代码示例来源:origin: konsoletyper/teavm
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;
}
代码示例来源:origin: robovm/robovm
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
代码示例来源:origin: robovm/robovm
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
代码示例来源:origin: robovm/robovm
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
代码示例来源:origin: robovm/robovm
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
代码示例来源:origin: robovm/robovm
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
代码示例来源:origin: robovm/robovm
if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
代码示例来源:origin: konsoletyper/teavm
@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);
}
代码示例来源:origin: com.google.protobuf/protobuf-java
|| !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);
代码示例来源:origin: com.google.protobuf/protobuf-java
if (inIx + 1 == inLength || !isSurrogatePair(c, (low = in.charAt(++inIx)))) {
throw new UnpairedSurrogateException(inIx, inLength);
代码示例来源:origin: konsoletyper/teavm
@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);
}
代码示例来源:origin: konsoletyper/teavm
@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;
}
代码示例来源:origin: fengjiachun/Jupiter
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)))) {
代码示例来源:origin: fengjiachun/Jupiter
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)))) {
代码示例来源:origin: fengjiachun/Jupiter
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)))) {
代码示例来源:origin: fengjiachun/Jupiter
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)))) {
代码示例来源:origin: com.google.protobuf/protobuf-java
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)))) {
代码示例来源:origin: com.google.protobuf/protobuf-java
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)))) {
代码示例来源:origin: org.apache.lucene/lucene-analyzers-common
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) {
内容来源于网络,如有侵权,请联系作者删除!