本文整理了Java中java.lang.Character.codePointAt()
方法的一些代码示例,展示了Character.codePointAt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Character.codePointAt()
方法的具体详情如下:
包路径:java.lang.Character
类名称:Character
方法名:codePointAt
[英]Returns the code point at index in the specified sequence of character units. If the unit at index is a high-surrogate unit, index + 1 is less than the length of the sequence and the unit at index + 1 is a low-surrogate unit, then the supplementary code point represented by the pair is returned; otherwise the charvalue at index is returned.
[中]
代码示例来源:origin: libgdx/libgdx
/** Retrieves the Unicode code point value at the {@code index}.
*
* @param index the index to the {@code char} code unit.
* @return the Unicode code point value.
* @throws IndexOutOfBoundsException if {@code index} is negative or greater than or equal to {@link #length()}.
* @see Character
* @see Character#codePointAt(char[], int, int)
* @since 1.5 */
public int codePointAt (int index) {
if (index < 0 || index >= length) {
throw new StringIndexOutOfBoundsException(index);
}
return Character.codePointAt(chars, index, length);
}
代码示例来源:origin: libgdx/libgdx
/** Retrieves the Unicode code point value at the {@code index}.
*
* @param index the index to the {@code char} code unit.
* @return the Unicode code point value.
* @throws IndexOutOfBoundsException if {@code index} is negative or greater than or equal to {@link #length()}.
* @see Character
* @see Character#codePointAt(char[], int, int)
* @since 1.5 */
public int codePointAt (int index) {
if (index < 0 || index >= length) {
throw new StringIndexOutOfBoundsException(index);
}
return Character.codePointAt(chars, index, length);
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Implementation of translate that maps onto the abstract translate(int, Writer) method.
* {@inheritDoc}
*/
@Override
public final int translate(final CharSequence input, final int index, final Writer out) throws IOException {
final int codepoint = Character.codePointAt(input, index);
final boolean consumed = translate(codepoint, out);
return consumed ? 1 : 0;
}
代码示例来源:origin: google/guava
private static int encodedLengthGeneral(CharSequence sequence, int start) {
int utf16Length = sequence.length();
int utf8Length = 0;
for (int i = start; i < utf16Length; i++) {
char c = sequence.charAt(i);
if (c < 0x800) {
utf8Length += (0x7f - c) >>> 31; // branch free!
} else {
utf8Length += 2;
// jdk7+: if (Character.isSurrogate(c)) {
if (MIN_SURROGATE <= c && c <= MAX_SURROGATE) {
// Check that we have a well-formed surrogate pair.
if (Character.codePointAt(sequence, i) == c) {
throw new IllegalArgumentException(unpairedSurrogateMsg(i));
}
i++;
}
}
}
return utf8Length;
}
代码示例来源:origin: redisson/redisson
private static int[] toCodePoints(char[] str) {
int[] codePoints = new int[Character.codePointCount(str, 0, str.length)];
for (int i = 0, c = 0; i < str.length; c++) {
int cp = Character.codePointAt(str, i);
codePoints[c] = cp;
i += Character.charCount(cp);
}
return codePoints;
}
代码示例来源:origin: oracle/opengrok
private static int nextTestWhitespaceLength(boolean match, String str,
int off) {
int i = 0;
while (off + i < str.length()) {
int cp = Character.codePointAt(str, off + i);
if ((Character.isWhitespace(cp) || Character.isISOControl(cp)) !=
match) {
return i;
}
i += Character.charCount(cp);
}
return str.length() - off;
}
代码示例来源:origin: speedment/speedment
private String codePoints(String c) {
final StringJoiner str = new StringJoiner(" ");
for (int i = 0; i < c.length(); i++) {
str.add(String.valueOf(Character.codePointAt(c, i)));
}
return str.toString();
}
代码示例来源:origin: prestodb/presto
private static int encodedLengthGeneral(CharSequence sequence, int start) {
int utf16Length = sequence.length();
int utf8Length = 0;
for (int i = start; i < utf16Length; i++) {
char c = sequence.charAt(i);
if (c < 0x800) {
utf8Length += (0x7f - c) >>> 31; // branch free!
} else {
utf8Length += 2;
// jdk7+: if (Character.isSurrogate(c)) {
if (MIN_SURROGATE <= c && c <= MAX_SURROGATE) {
// Check that we have a well-formed surrogate pair.
if (Character.codePointAt(sequence, i) == c) {
throw new IllegalArgumentException(unpairedSurrogateMsg(i));
}
i++;
}
}
}
return utf8Length;
}
代码示例来源:origin: wildfly/wildfly
public int peekNext() throws NoSuchElementException {
if (! hasNext()) throw new NoSuchElementException();
return Character.codePointAt(chars, offs + idx);
}
代码示例来源:origin: wildfly/wildfly
public int peekNext() throws NoSuchElementException {
if (! hasNext()) throw new NoSuchElementException();
return Character.codePointAt(chars, offs + idx);
}
代码示例来源:origin: robovm/robovm
/**
* Returns the Unicode code point at the given {@code index}.
*
* @throws IndexOutOfBoundsException if {@code index < 0 || index >= length()}
* @see Character#codePointAt(char[], int, int)
* @since 1.5
*/
public int codePointAt(int index) {
if (index < 0 || index >= count) {
throw indexAndLength(index);
}
return Character.codePointAt(value, offset + index, offset + count);
}
代码示例来源:origin: google/j2objc
private static int encodedLengthGeneral(CharSequence sequence, int start) {
int utf16Length = sequence.length();
int utf8Length = 0;
for (int i = start; i < utf16Length; i++) {
char c = sequence.charAt(i);
if (c < 0x800) {
utf8Length += (0x7f - c) >>> 31; // branch free!
} else {
utf8Length += 2;
// jdk7+: if (Character.isSurrogate(c)) {
if (MIN_SURROGATE <= c && c <= MAX_SURROGATE) {
// Check that we have a well-formed surrogate pair.
if (Character.codePointAt(sequence, i) == c) {
throw new IllegalArgumentException(unpairedSurrogateMsg(i));
}
i++;
}
}
}
return utf8Length;
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
private static int[] toCodePoints(char[] str) {
int[] codePoints = new int[Character.codePointCount(str, 0, str.length)];
for (int i = 0, c = 0; i < str.length; c++) {
int cp = Character.codePointAt(str, i);
codePoints[c] = cp;
i += Character.charCount(cp);
}
return codePoints;
}
代码示例来源:origin: AsyncHttpClient/async-http-client
private static StringBuilder appendEncoded(StringBuilder sb, CharSequence input, BitSet dontNeedEncoding, boolean encodeSpaceAsPlus) {
int c;
for (int i = 0; i < input.length(); i += Character.charCount(c)) {
c = Character.codePointAt(input, i);
if (c <= 127) {
if (dontNeedEncoding.get(c)) {
sb.append((char) c);
} else {
appendSingleByteEncoded(sb, c, encodeSpaceAsPlus);
}
} else {
appendMultiByteEncoded(sb, c);
}
}
return sb;
}
代码示例来源:origin: wildfly/wildfly
public int next() {
if (! hasNext()) throw new NoSuchElementException();
try {
offset++;
return Character.codePointAt(chars, offs + idx);
} finally {
idx = Character.offsetByCodePoints(chars, offs, len, offs + idx, 1) - offs;
}
}
代码示例来源:origin: wildfly/wildfly
public int previous() {
if (! hasPrevious()) throw new NoSuchElementException();
idx = Character.offsetByCodePoints(chars, offs, len, offs + idx, - 1) - offs;
offset--;
return Character.codePointAt(chars, offs + idx);
}
代码示例来源:origin: wildfly/wildfly
public int prev() {
if (! hasPrev()) throw new NoSuchElementException();
idx = Character.offsetByCodePoints(chars, offs, len, offs + idx, -1) - offs;
offset--;
return Character.codePointAt(chars, offs + idx);
}
代码示例来源:origin: wildfly/wildfly
public int next() {
if (! hasNext()) throw new NoSuchElementException();
try {
offset++;
return Character.codePointAt(chars, offs + idx);
} finally {
idx = Character.offsetByCodePoints(chars, offs, len, offs + idx, 1) - offs;
}
}
代码示例来源:origin: google/guava
update(3, charToThreeUtf8Bytes(c));
} else {
int codePoint = Character.codePointAt(input, i);
if (codePoint == c) {
代码示例来源:origin: google/guava
len += 3;
} else {
int codePoint = Character.codePointAt(input, i);
if (codePoint == c) {
内容来源于网络,如有侵权,请联系作者删除!