MCPcopy Create free account
hub / github.com/davidgiven/luje / codePointBefore

Method codePointBefore

lib/java/lang/Character.java:2303–2321  ·  view source on GitHub ↗

Returns the code point that preceds index in the specified sequence of character units. If the unit at index - 1 is a low-surrogate unit, index - 2 is not negative and the unit at index - 2 is a high-surrogate unit, then the supplementary code point represented by the

(CharSequence seq, int index)

Source from the content-addressed store, hash-verified

2301 * @since 1.5
2302 */
2303 public static int codePointBefore(CharSequence seq, int index) {
2304 if (seq == null) {
2305 throw new NullPointerException();
2306 }
2307 int len = seq.length();
2308 if (index < 1 || index > len) {
2309 throw new StringIndexOutOfBoundsException(index);
2310 }
2311
2312 char low = seq.charAt(--index);
2313 if (--index < 0) {
2314 return low;
2315 }
2316 char high = seq.charAt(index);
2317 if (isSurrogatePair(high, low)) {
2318 return toCodePoint(high, low);
2319 }
2320 return low;
2321 }
2322
2323 /**
2324 * Returns the code point that preceds {@code index} in the specified

Callers 2

codePointBeforeMethod · 0.95
codePointBeforeMethod · 0.95

Calls 4

isSurrogatePairMethod · 0.95
toCodePointMethod · 0.95
lengthMethod · 0.65
charAtMethod · 0.65

Tested by

no test coverage detected