public int characterAt(int at) throws JSONException {
        int c = get(at);
        if ((c & 0x80) == 0) {
            return c;
        }
        int character;
        int c1 = get(at + 1);
        if ((c1 & 0x80) == 0) {
            character = ((c & 0x7F) << 7) | c1;
            if (character > 0x7F) {
                return character;
            }
        } else {
            int c2 = get(at + 2);
            character = ((c & 0x7F) << 14) | ((c1 & 0x7F) << 7) | c2;
            if ((c2 & 0x80) == 0 && character > 0x3FFF && character <= 0x10FFFF
                    && (character < 0xD800 || character > 0xDFFF)) {
                return character;
            }
        }
        throw new JSONException("Bad character at " + at);
    }