/** 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); }
/** 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); }
/** * 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; }
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; }
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; }
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; }
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(); }
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; }
public int peekNext() throws NoSuchElementException { if (! hasNext()) throw new NoSuchElementException(); return Character.codePointAt(chars, offs + idx); }
public int peekNext() throws NoSuchElementException { if (! hasNext()) throw new NoSuchElementException(); return Character.codePointAt(chars, offs + idx); }
/** * 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); }
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; }
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; }
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; }
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; } }
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); }
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); }
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; } }
update(3, charToThreeUtf8Bytes(c)); } else { int codePoint = Character.codePointAt(input, i); if (codePoint == c) {
len += 3; } else { int codePoint = Character.codePointAt(input, i); if (codePoint == c) {