本文整理汇总了Java中com.ibm.icu.lang.UCharacter.isHighSurrogate方法的典型用法代码示例。如果您正苦于以下问题:Java UCharacter.isHighSurrogate方法的具体用法?Java UCharacter.isHighSurrogate怎么用?Java UCharacter.isHighSurrogate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.lang.UCharacter
的用法示例。
在下文中一共展示了UCharacter.isHighSurrogate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: char32AtAndAdvance
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
private static int char32AtAndAdvance(AttributedCharacterIterator iterator) {
char c1 = iterator.current();
char c2 = iterator.next();
if (UCharacter.isHighSurrogate(c1)) {
// If c2 is DONE, it will fail the low surrogate test and we
// skip this block.
if (UCharacter.isLowSurrogate(c2)) {
iterator.next();
return UCharacter.toCodePoint(c1, c2);
}
}
return c1;
}
示例2: separated
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Return the string with interspersed CGJs. Input must have more than 2 codepoints.
* <p>This is used to test whether contractions sort differently from their components.
*/
private String separated(String item) {
StringBuilder result = new StringBuilder();
// add a CGJ except within surrogates
char last = item.charAt(0);
result.append(last);
for (int i = 1; i < item.length(); ++i) {
char ch = item.charAt(i);
if (!UCharacter.isHighSurrogate(last) || !UCharacter.isLowSurrogate(ch)) {
result.append(CGJ);
}
result.append(ch);
last = ch;
}
return result.toString();
}
示例3: dirTypeForward
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Returns the UCharacter.DIRECTIONALITY_... value of the next codepoint and advances charIndex.
* If isHtml, and the codepoint is '<' or '&', advances through the tag/entity, and returns an
* appropriate dirtype.
*
* @throws java.lang.IndexOutOfBoundsException if called when charIndex >= length or < 0.
*/
@VisibleForTesting
byte dirTypeForward() {
lastChar = text.charAt(charIndex);
if (UCharacter.isHighSurrogate(lastChar)) {
int codePoint = UCharacter.codePointAt(text, charIndex);
charIndex += UCharacter.charCount(codePoint);
return UCharacter.getDirectionality(codePoint);
}
charIndex++;
byte dirType = getCachedDirectionality(lastChar);
if (isHtml) {
// Process tags and entities.
if (lastChar == '<') {
dirType = skipTagForward();
} else if (lastChar == '&') {
dirType = skipEntityForward();
}
}
return dirType;
}
示例4: characters
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* @see nu.validator.htmlparser.common.CharacterHandler#characters(char[], int, int)
*/
public void characters(char[] ch, int start, int length)
throws SAXException {
if (alreadyComplainedAboutThisRun) {
return;
}
if (atStartOfRun) {
char c = ch[start];
if (pos == 1) {
// there's a single high surrogate in buf
if (isComposingChar(UCharacter.getCodePoint(buf[0], c))) {
err("Text run starts with a composing character.");
}
atStartOfRun = false;
} else {
if (length == 1 && UCharacter.isHighSurrogate(c)) {
buf[0] = c;
pos = 1;
return;
} else {
if (UCharacter.isHighSurrogate(c)) {
if (isComposingChar(UCharacter.getCodePoint(c,
ch[start + 1]))) {
err("Text run starts with a composing character.");
}
} else {
if (isComposingCharOrSurrogate(c)) {
err("Text run starts with a composing character.");
}
}
atStartOfRun = false;
}
}
}
int i = start;
int stop = start + length;
if (pos > 0) {
// there's stuff in buf
while (i < stop && isComposingCharOrSurrogate(ch[i])) {
i++;
}
appendToBuf(ch, start, i);
if (i == stop) {
return;
} else {
if (!Normalizer.isNormalized(buf, 0, pos, Normalizer.NFC, 0)) {
errAboutTextRun();
}
pos = 0;
}
}
if (i < stop) {
start = i;
i = stop - 1;
while (i > start && isComposingCharOrSurrogate(ch[i])) {
i--;
}
if (i > start) {
if (!Normalizer.isNormalized(ch, start, i, Normalizer.NFC, 0)) {
errAboutTextRun();
}
}
appendToBuf(ch, i, stop);
}
}
示例5: isComposingCharOrSurrogate
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Returns <code>true</code> if the argument is a composing BMP character
* or a surrogate and <code>false</code> otherwise.
*
* @param c a UTF-16 code unit
* @return <code>true</code> if the argument is a composing BMP character
* or a surrogate and <code>false</code> otherwise
*/
private static boolean isComposingCharOrSurrogate(char c) {
if (UCharacter.isHighSurrogate(c) || UCharacter.isLowSurrogate(c)) {
return true;
}
return isComposingChar(c);
}