本文整理了Java中java.lang.Character.isSurrogate()
方法的一些代码示例,展示了Character.isSurrogate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Character.isSurrogate()
方法的具体详情如下:
包路径:java.lang.Character
类名称:Character
方法名:isSurrogate
[英]Returns true if the given character is a high or low surrogate.
[中]如果给定字符是高代理项或低代理项,则返回true。
代码示例来源:origin: apache/incubator-druid
public static int estimatedBinaryLengthAsUTF8(String value)
{
int length = 0;
for (int i = 0; i < value.length(); i++) {
char var10 = value.charAt(i);
if (var10 < 0x80) {
length += 1;
} else if (var10 < 0x800) {
length += 2;
} else if (Character.isSurrogate(var10)) {
length += 4;
i++;
} else {
length += 3;
}
}
return length;
}
代码示例来源:origin: konsoletyper/teavm
private boolean hasBadCharacters(String string) {
for (int i = 0; i < string.length(); ++i) {
char c = string.charAt(i);
if (c == 0 || Character.isSurrogate(c)) {
return true;
}
}
return false;
}
代码示例来源:origin: apache/hive
public static String getRandUnicodeString(Random r, int length) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++) {
char ch;
while (true) {
int codePoint = MIN_RANDOM_CODEPOINT + r.nextInt(RANGE_RANDOM_CODEPOINT);
if (!Character.isDefined(codePoint) ||
Character.getType(codePoint) == Character.PRIVATE_USE) {
continue;
}
ch = (char) codePoint;
if (Character.isSurrogate(ch)) {
continue;
}
break;
}
sb.append(ch);
}
return sb.toString();
}
代码示例来源:origin: prestodb/presto
check(!Character.isSurrogate(currentCodePoint), format("Invalid escaped character: %s. Escaped character is a surrogate. Use '\\+123456' instead.", currentEscapedCode), context);
unicodeStringBuilder.append(currentCodePoint);
代码示例来源:origin: rapidoid/rapidoid
out.writeByte((byte) (UTF8_CONTINUATION | c & LAST_6)); // lowest 6 bits
} else if (Character.isSurrogate(c)) {
代码示例来源:origin: konsoletyper/teavm
} else if (!Character.isSurrogate(ch)) {
if (outPos + 3 > outSize) {
--inPos;
代码示例来源:origin: stackoverflow.com
public static boolean isEntirelyInBasicMultilingualPlane(String text) {
for (int i = 0; i < text.length(); i++) {
if (Character.isSurrogate(text.charAt(i))) {
return false;
}
}
return true;
}
代码示例来源:origin: stackoverflow.com
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("1.txt"), "UTF-8"));
for (int c; (c = br.read()) != -1;) {
if (Character.isSurrogate((char)c)) {
// skip the second surrogate char
br.read();
} else {
// process char c
}
}
代码示例来源:origin: rapidoid/rapidoid
out.writeByte((byte) (UTF8_CONTINUATION | c & LAST_6)); // lowest 6 bits
} else if (Character.isSurrogate(c)) {
代码示例来源:origin: konsoletyper/teavm
if (Character.isSurrogate(c)) {
inPos -= 3;
result = TCoderResult.malformedForLength(3);
代码示例来源:origin: org.kopitubruk.util/JSONUtil
/**
* Shorthand for doing boolean isSurrogate as an int.
*
* @param ch the char to check
* @return 1 if it's a surrogate. 0 if not.
*/
private static int isSurrogate( char ch )
{
return Character.isSurrogate(ch) ? 1 : 0;
}
代码示例来源:origin: bluestreak01/questdb
/**
* Determines if the specified code point is a supplementary
* character or unpaired surrogate.
*/
private static boolean isSupplementary(int ch) {
return ch >= Character.MIN_SUPPLEMENTARY_CODE_POINT ||
Character.isSurrogate((char) ch);
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul
/**
* Determines if the specified code point is a supplementary
* character or unpaired surrogate.
*/
private static final boolean isSupplementary(int ch) {
return ch >= Character.MIN_SUPPLEMENTARY_CODE_POINT ||
Character.isSurrogate((char)ch);
}
代码示例来源:origin: jtulach/bck2brwsr
/**
* Determines if the specified code point is a supplementary
* character or unpaired surrogate.
*/
private static final boolean isSupplementary(int ch) {
return ch >= Character.MIN_SUPPLEMENTARY_CODE_POINT ||
Character.isSurrogate((char)ch);
}
代码示例来源:origin: org.kopitubruk.util/JSONUtil
public boolean needEscapeImpl( char ch )
{
return isControl(ch) || isEsc(ch) || Character.isSurrogate(ch);
}
代码示例来源:origin: org.kopitubruk.util/JSONUtil
public boolean needEscapeImpl( char ch )
{
return isControl(ch) || isEvalEsc(ch) || Character.isSurrogate(ch);
}
代码示例来源:origin: org.talend.daikon/daikon
private static int getConsecutiveCodepoints(int codePoint, String pattern, int currentPos) {
int lastPos = currentPos;
while (lastPos < pattern.length() && pattern.codePointAt(lastPos) == codePoint) {
if (Character.isSurrogate(pattern.charAt(lastPos)))
lastPos += 2;
else
lastPos++;
}
return (lastPos - currentPos + 1);
}
代码示例来源:origin: stackoverflow.com
Character.isHighSurrogate(myChar); // returns true if myChar is a high surrogate
Character.isLowSurrogate(myChar); // same for low surrogate
Character.isSurrogate(myChar); // just to know if myChar is a surrogate
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
public String removeSurrogates(String str) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (!Character.isSurrogate(c)) {
sb.append(c);
}
else if (restrictReplacement != null) {
sb.append(restrictReplacement);
}
}
return sb.toString();
}
代码示例来源:origin: bluestreak01/questdb
private int putUtf8Internal(CharSequence cs, int hi, int i, char c) {
if (c < 2048) {
put((char) (192 | c >> 6)).put((char) (128 | c & 63));
} else if (Character.isSurrogate(c)) {
i = encodeSurrogate(c, cs, i, hi);
} else {
put((char) (224 | c >> 12)).put((char) (128 | c >> 6 & 63)).put((char) (128 | c & 63));
}
return i;
}
内容来源于网络,如有侵权,请联系作者删除!