本文整理汇总了Java中com.ibm.icu.text.UTF16.isSurrogate方法的典型用法代码示例。如果您正苦于以下问题:Java UTF16.isSurrogate方法的具体用法?Java UTF16.isSurrogate怎么用?Java UTF16.isSurrogate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.text.UTF16
的用法示例。
在下文中一共展示了UTF16.isSurrogate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decompose
import com.ibm.icu.text.UTF16; //导入方法依赖的package包/类
public int decompose(CharSequence s, int src, int limit,
ReorderingBuffer buffer) {
int minNoCP=minDecompNoCP;
int prevSrc;
int c=0;
int norm16=0;
// only for quick check
int prevBoundary=src;
int prevCC=0;
for(;;) {
// count code units below the minimum or with irrelevant data for the quick check
for(prevSrc=src; src!=limit;) {
if( (c=s.charAt(src))<minNoCP ||
isMostDecompYesAndZeroCC(norm16=normTrie.getFromU16SingleLead((char)c))
) {
++src;
} else if(!UTF16.isSurrogate((char)c)) {
break;
} else {
char c2;
if(UTF16Plus.isSurrogateLead(c)) {
if((src+1)!=limit && Character.isLowSurrogate(c2=s.charAt(src+1))) {
c=Character.toCodePoint((char)c, c2);
}
} else /* trail surrogate */ {
if(prevSrc<src && Character.isHighSurrogate(c2=s.charAt(src-1))) {
--src;
c=Character.toCodePoint(c2, (char)c);
}
}
if(isMostDecompYesAndZeroCC(norm16=getNorm16(c))) {
src+=Character.charCount(c);
} else {
break;
}
}
}
// copy these code units all at once
if(src!=prevSrc) {
if(buffer!=null) {
buffer.flushAndAppendZeroCC(s, prevSrc, src);
} else {
prevCC=0;
prevBoundary=src;
}
}
if(src==limit) {
break;
}
// Check one above-minimum, relevant code point.
src+=Character.charCount(c);
if(buffer!=null) {
decompose(c, norm16, buffer);
} else {
if(isDecompYes(norm16)) {
int cc=getCCFromYesOrMaybe(norm16);
if(prevCC<=cc || cc==0) {
prevCC=cc;
if(cc<=1) {
prevBoundary=src;
}
continue;
}
}
return prevBoundary; // "no" or cc out of order
}
}
return src;
}
示例2: findWord
import com.ibm.icu.text.UTF16; //导入方法依赖的package包/类
public static IRegion findWord(IDocument document, int offset) {
int start= -2;
int end= -1;
try {
int pos= offset;
char c;
while (pos >= 0) {
c= document.getChar(pos);
if (!Character.isJavaIdentifierPart(c)) {
// Check for surrogates
if (UTF16.isSurrogate(c)) {
/*
* XXX: Here we should create the code point and test whether
* it is a Java identifier part. Currently this is not possible
* because java.lang.Character in 1.4 does not support surrogates
* and because com.ibm.icu.lang.UCharacter.isJavaIdentifierPart(int)
* is not correctly implemented.
*/
} else {
break;
}
}
--pos;
}
start= pos;
pos= offset;
int length= document.getLength();
while (pos < length) {
c= document.getChar(pos);
if (!Character.isJavaIdentifierPart(c)) {
if (UTF16.isSurrogate(c)) {
/*
* XXX: Here we should create the code point and test whether
* it is a Java identifier part. Currently this is not possible
* because java.lang.Character in 1.4 does not support surrogates
* and because com.ibm.icu.lang.UCharacter.isJavaIdentifierPart(int)
* is not correctly implemented.
*/
} else {
break;
}
}
++pos;
}
end= pos;
} catch (BadLocationException x) {
}
if (start >= -1 && end > -1) {
if (start == offset && end == offset)
return new Region(offset, 0);
else if (start == offset)
return new Region(start, end - start);
else
return new Region(start + 1, end - start - 1);
}
return null;
}