Java Char Code Get CodePointAt(String str, int index, int endIndex)

Here you can find the source of CodePointAt(String str, int index, int endIndex)

Description

Code Point At

License

Creative Commons License

Declaration

private static int CodePointAt(String str, int index, int endIndex) 

Method Source Code

//package com.java2s;

public class Main {
    private static int CodePointAt(String str, int index, int endIndex) {
        if (str == null) {
            throw new NullPointerException("str");
        }/*from   ww w  . j  a  va  2  s . co m*/
        if (index >= endIndex) {
            return -1;
        }
        if (index < 0) {
            return -1;
        }
        int c = str.charAt(index);
        if ((c & 0xfc00) == 0xd800 && index + 1 < endIndex && str.charAt(index + 1) >= 0xdc00
                && str.charAt(index + 1) <= 0xdfff) {
            // Get the Unicode code point for the surrogate pair
            c = 0x10000 + ((c - 0xd800) << 10) + (str.charAt(index + 1) - 0xdc00);
            ++index;
        } else if ((c & 0xf800) == 0xd800) {
            // unpaired surrogate
            return 0xfffd;
        }
        return c;
    }
}

Related

  1. codePointAt(char[] s, int i)
  2. codePointAt(final char c1, final char c2)
  3. codePointAt(String _this, int index)
  4. CodePointAt(String str, int index)
  5. codePointAt(String theString, int point)