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)
| 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 |
no test coverage detected