Method to read a partular character string.
only really need to handle 'null', 'true', and 'false'
960026
private String readIdentifier() throws IOException {
        StringBuffer sb = new StringBuffer();

        while ((-1 != lastChar) && Character.isLetter((char)lastChar))
        {
            sb.append((char)lastChar);
            readChar();
        }

        return sb.toString();
    }
229847
private void parseCharData() throws Exception {
        char c;
        int state = 0;
        boolean pureWhite = false;

        // assert (dataBufferPos == 0);

        // are we expecting pure whitespace? it might be dirty...
        if ((currentElementContent == CONTENT_ELEMENTS)
                && !isDirtyCurrentElement) {
            pureWhite = true;
        }

        // always report right out of readBuffer
        // to minimize (pointless) buffer copies
        while (true) {
            int i;

            loop: for (i = readBufferPos; i < readBufferLength; i++) {
                advanceLocation();
                switch (c = readBuffer[i]) {
                    case '\n':
                        nextCharOnNewLine = true;
                        // pureWhite unmodified
                        break;
                    case '\r': // should not happen!!
                    case '\t':
                    case ' ':
                        // pureWhite unmodified
                        break;
                    case '&':
                    case '<':
                        // pureWhite unmodified
                        // CLEAN end of text sequence
                        state = 1;
                        rollbackLocation();
                        break loop;
                    case ']':
                        // that's not a whitespace char, and
                        // can not terminate pure whitespace either
                        pureWhite = false;
                        // Refill buffer if needed -- 2008-03-06 hsivonen
                        if (readBufferOverflow == -1) {
                            if ((i + 2) >= readBufferLength) {
                                reportText(pureWhite, i);
                                readBufferOverflow = ']';
                                fillBuffer();
                                i = readBufferPos;
                            }
                            if ((readBuffer[i + 1] == ']')
                                    && (readBuffer[i + 2] == '>')) {
                                // ERROR end of text sequence
                                state = 2;
                                rollbackLocation();
                                break loop;
                            }
                        }
                        break;
                    default:
                        if (((c < 0x0020) || (c > 0xFFFD))
                                || ((c >= 0x007f) && (c <= 0x009f)
                                        && (c != 0x0085) && (xmlVersion == XML_11))) {
                            fatal("illegal XML character U+"
                                    + Integer.toHexString(c));
                        } else if ((c >= '\u007F') && (c <= '\u009F')) // 2006-04-25
                        // hsivonen
                        {
                            handler.warn("Saw a control character: U+00"
                                    + Integer.toHexString(c) + ".");
                        }
                        // that's not a whitespace char
                        pureWhite = false;
                }
            }
            // report characters/whitspace
            reportText(pureWhite, i);

            if (state != 0) {
                break;
            }

            // fill next buffer from this entity, or
            // pop stack and continue with previous entity
            unread(readCh());
        }
        if (!pureWhite) {
            isDirtyCurrentElement = true;
        }
        // finish, maybe with error
        if (state != 1) // finish, no error
        {
            fatal("character data may not contain ']]>'");
        }
    }
1301801
private static int readValue(CharSequence chars, int pos, int leadUnit) {
        int value;
        if(leadUnit<kMinTwoUnitValueLead) {
            value=leadUnit;
        } else if(leadUnit<kThreeUnitValueLead) {
            value=((leadUnit-kMinTwoUnitValueLead)<<16)|chars.charAt(pos);
        } else {
            value=(chars.charAt(pos)<<16)|chars.charAt(pos+1);
        }
        return value;
    }
273586
String scanString()
    throws IOException
  {
    int ch = read();
    
    switch (ch) {
    case 'N':
      return null;
      
    case 0x00: case 0x01: case 0x02: case 0x03:
    case 0x04: case 0x05: case 0x06: case 0x07:
    case 0x08: case 0x09: case 0x0a: case 0x0b:
    case 0x0c: case 0x0d: case 0x0e: case 0x0f:
      
    case 0x10: case 0x11: case 0x12: case 0x13:
    case 0x14: case 0x15: case 0x16: case 0x17:
    case 0x18: case 0x19: case 0x1a: case 0x1b:
    case 0x1c: case 0x1d: case 0x1e: case 0x1f:
      return readString(ch - 0x00);
      
    default:
      throw new UnsupportedOperationException(getClass().getName());
    }
  }
466725
private int scan(String string, int i, CharBuffer cb, boolean dash)
    throws Exception
  {
    char ch;

    cb.length(0);

    int strlen = string.length();
    for (; i < strlen; i++) {
      if (! Character.isWhitespace(ch = string.charAt(i)) &&
          (ch != ':' && (! dash || ch != '-')))
        break;
    }

    for (; i < strlen; i++) {
      if (! Character.isWhitespace(ch = string.charAt(i)) &&
          (ch != ':' && (! dash || ch != '-')))
        cb.append((char) ch);
      else
        break;
    }

    if (cb.length() == 0)
      throw new Exception();

    return i;
  }
736831
@Override
    public char[] read(ScanBuffer buffer) {
        int length = getLength(buffer);
        if (length<0) return null;
        return buffer.getChars(length);
    }
994928
@Override
    public String readString() {
        final char[] text0 = this.text;
        int currpos = this.position;
        char expected = text0[++currpos];
        if (expected <= ' ') {
            for (;;) {
                expected = text0[++currpos];
                if (expected > ' ') break;
            }
        }
        if (expected != '"' && expected != '\'') {
            if (expected == 'n' && text0.length > currpos + 3 && (text0[1 + currpos] == 'u' && text0[2 + currpos] == 'l' && text0[3 + currpos] == 'l')) {
                if (text0[++currpos] == 'u' && text0[++currpos] == 'l' && text0[++currpos] == 'l') {
                    this.position = currpos;
                    if (text0.length > currpos + 4) {
                        char ch = text0[currpos + 1];
                        if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') return null;
                        final int start = currpos - 3;
                        for (;;) {
                            if (currpos >= text0.length) break;
                            ch = text0[currpos];
                            if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') break;
                            currpos++;
                        }
                        if (currpos == start) throw new ConvertException("expected a string after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")");
                        this.position = currpos - 1;
                        return new String(text0, start, currpos - start);
                    } else {
                        return null;
                    }
                }
            } else {
                final int start = currpos;
                for (;;) {
                    if (currpos >= text0.length) break;
                    char ch = text0[currpos];
                    if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') break;
                    currpos++;
                }
                if (currpos == start) throw new ConvertException("expected a string after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")");
                this.position = currpos - 1;
                return new String(text0, start, currpos - start);
            }
            this.position = currpos;
            throw new ConvertException("expected a ':' after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")");
        }
        final int start = ++currpos;
        for (;;) {
            char ch = text0[currpos];
            if (ch == expected) {
                break;
            } else if (ch == '\\') {
                this.position = currpos - 1;
                return readEscapeValue(expected, start);
            }
            currpos++;
        }
        this.position = currpos;
        return new String(text0, start, currpos - start);
    }
417517
protected String readStringImpl(int length)
        throws IOException
    {
        StringBuffer sb = new StringBuffer();

        for (int i = 0; i < length; i++) {
            int ch = is.read();

            if (ch < 0x80)
                sb.append((char) ch);
            else if ((ch & 0xe0) == 0xc0) {
                int ch1 = is.read();
                int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f);

                sb.append((char) v);
            }
            else if ((ch & 0xf0) == 0xe0) {
                int ch1 = is.read();
                int ch2 = is.read();
                int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f);

                sb.append((char) v);
            }
            else
                throw new IOException("bad utf-8 encoding");
        }

        return sb.toString();
    }
1074309
function (checks) {
    this.from = this.char;

    // Move to the next non-space character.
    var start;
    if (/\s/.test(this.peek())) {
      start = this.char;

      while (/\s/.test(this.peek())) {
        this.from += 1;
        this.skip();
      }
    }

    // Methods that work with multi-line structures and move the
    // character pointer.

    var match = this.scanComments() ||
      this.scanStringLiteral(checks) ||
      this.scanTemplateLiteral();

    if (match) {
      return match;
    }

    // Methods that don't move the character pointer.

    match =
      this.scanRegExp() ||
      this.scanPunctuator() ||
      this.scanKeyword() ||
      this.scanIdentifier() ||
      this.scanNumericLiteral();

    if (match) {
      this.skip(match.value.length);
      return match;
    }

    // No token could be matched, give up.

    return null;
  }
961398
private static void readChar(ByteToChar converter, 
                               CharReader is,
                               int ch, boolean isTop)
    throws IOException
  {
    if (ch == '+') {
      if (isTop)
        converter.addByte(' ');
      else
        converter.addChar(' ');
    }
    else if (ch == '%') {
      int ch1 = is.next();

      if (ch1 == 'u') {
        ch1 = is.next();
        int ch2 = is.next();
        int ch3 = is.next();
        int ch4 = is.next();

        converter.addChar((char) ((toHex(ch1) << 12) +
                                  (toHex(ch2) << 8) + 
                                  (toHex(ch3) << 4) + 
                                  (toHex(ch4))));
      }
      else {
        int ch2 = is.next();
        
        converter.addByte(((toHex(ch1) << 4) + toHex(ch2)));
      }
    }
    else if (isTop) {
      converter.addByte((byte) ch);
    }
    else {
      converter.addChar((char) ch);
    }
  }
1280169
private void scanIdent() {
        boolean isJavaIdentifierPart;
        char high;
        reader.putChar(true);
        do {
            switch (reader.ch) {
            case 'A': case 'B': case 'C': case 'D': case 'E':
            case 'F': case 'G': case 'H': case 'I': case 'J':
            case 'K': case 'L': case 'M': case 'N': case 'O':
            case 'P': case 'Q': case 'R': case 'S': case 'T':
            case 'U': case 'V': case 'W': case 'X': case 'Y':
            case 'Z':
            case 'a': case 'b': case 'c': case 'd': case 'e':
            case 'f': case 'g': case 'h': case 'i': case 'j':
            case 'k': case 'l': case 'm': case 'n': case 'o':
            case 'p': case 'q': case 'r': case 's': case 't':
            case 'u': case 'v': case 'w': case 'x': case 'y':
            case 'z':
            case '$': case '_':
            case '0': case '1': case '2': case '3': case '4':
            case '5': case '6': case '7': case '8': case '9':
                break;
            case '\u0000': case '\u0001': case '\u0002': case '\u0003':
            case '\u0004': case '\u0005': case '\u0006': case '\u0007':
            case '\u0008': case '\u000E': case '\u000F': case '\u0010':
            case '\u0011': case '\u0012': case '\u0013': case '\u0014':
            case '\u0015': case '\u0016': case '\u0017':
            case '\u0018': case '\u0019': case '\u001B':
            case '\u007F':
                reader.scanChar();
                continue;
            case '\u001A': // EOI is also a legal identifier part
                if (reader.bp >= reader.buflen) {
                    name = reader.name();
                    tk = tokens.lookupKind(name);
                    return;
                }
                reader.scanChar();
                continue;
            default:
                if (reader.ch < '\u0080') {
                    // all ASCII range chars already handled, above
                    isJavaIdentifierPart = false;
                } else {
                    if (Character.isIdentifierIgnorable(reader.ch)) {
                        reader.scanChar();
                        continue;
                    } else {
                        int codePoint = reader.peekSurrogates();
                        if (codePoint >= 0) {
                            if (isJavaIdentifierPart = Character.isJavaIdentifierPart(codePoint)) {
                                reader.putChar(true);
                            }
                        } else {
                            isJavaIdentifierPart = Character.isJavaIdentifierPart(reader.ch);
                        }
                    }
                }
                if (!isJavaIdentifierPart) {
                    name = reader.name();
                    tk = tokens.lookupKind(name);
                    return;
                }
            }
            reader.putChar(true);
        } while (true);
    }
918885
def read_string(buff, byteorder='big'):
    """"""
    length = read_numeric(USHORT, buff, byteorder)
    return buff.read(length).decode('utf-8')
46701
private static String scanForName(int pos, final char[] chars) {
      StringBuilder buf = new StringBuilder();
      while(pos < chars.length) {
         char ch = chars[pos++];
         switch(ch) {
            case ' ':
            case ']':
               return buf.toString();
            case '[':
            case '<':
            case '>':
            case '&':
            case '/':
               return "";
            default:
               if(ch < 0x20 || Character.isWhitespace(ch)) {
                  return "";
               } else {
                  buf.append(ch);
               }
         }
      }
      return "";
   }
1069806
public int readText(char []charBuffer, int charOffset, int charLength)
    throws IOException
  {
    byte []byteBuffer = _is.buffer();
    int byteOffset = _is.offset();
    int byteLength = _is.length();

    if (byteLength <= byteOffset || length() == 0) {
      if (! fillFrameBuffer()) {
        return -1;
      }

      byteOffset = _is.offset();
      byteLength = _is.length();
    }

    int charEnd = charOffset + charLength;
    int i = charOffset;

    int byteBegin = byteOffset;
    int byteEnd = (int) Math.min(byteLength, byteOffset + length());

    while (i < charEnd && byteOffset < byteEnd) {
      int d1 = byteBuffer[byteOffset++] & 0xff;

      char ch;

      if (d1 < 0x80) {
        ch = (char) d1;
      }
      else if ((d1 & 0xe0) == 0xc0) {
        int d2 = byteBuffer[byteOffset++] & 0xff;

        ch = (char) (((d1 & 0x1f) << 6) + (d2 & 0x3f));

        if (d2 < 0) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if ((d2 & 0xc0) != 0x80) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if (ch < 0x80) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
      }
      else if ((d1 & 0xf0) == 0xe0){
        int d2 = byteBuffer[byteOffset++] & 0xff;
        int d3 = byteBuffer[byteOffset++] & 0xff;

        ch = (char) (((d1 & 0x0f) << 12) + ((d2 & 0x3f) << 6) + (d3 & 0x3f));

        if (d3 < 0) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if ((d2 & 0xc0) != 0x80) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if ((d3 & 0xc0) != 0x80) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if (ch < 0x800) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if (0xd800 <= ch && ch <= 0xdfff) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
      }
      else if ((d1 & 0xf8) == 0xf0){
        int d2 = byteBuffer[byteOffset++] & 0xff;
        int d3 = byteBuffer[byteOffset++] & 0xff;
        int d4 = byteBuffer[byteOffset++] & 0xff;

        int cp = (((d1 & 0x7) << 18)
                   + ((d2 & 0x3f) << 12)
                   + ((d3 & 0x3f) << 6)
                   + ((d4 & 0x3f)));

        cp -= 0x10000;

        char h = (char) (0xd800 + ((cp >> 10) & 0x3ff));

        charBuffer[i++] = h;

        ch = (char) (0xdc00 + (cp & 0x3ff));

        if (d4 < 0) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if ((d2 & 0xc0) != 0x80) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if ((d3 & 0xc0) != 0x80) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if ((d4 & 0xc0) != 0x80) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if (cp < 0x0) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
        else if (cp >= 0x100000) {
          closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");
          ch = UTF8_ERROR;
        }
      }
      else {
        closeError(CloseCodes.NOT_CONSISTENT, "illegal utf-8");

        ch = UTF8_ERROR;
      }

      charBuffer[i++] = ch;
    }

    _is.offset(byteOffset);
    _length -= (byteOffset - byteBegin);

    return i - charOffset;
  }
149601
def _get_char(self):
        

        if self.ungotten_char is None:
            if self.eof:
                c = ''
            else:
                c = self.file.read(1)
                if c == '':
                    self.eof = True
                elif c == '\n':
                    self.line_number += 1
        else:
            c = self.ungotten_char
            self.ungotten_char = None
        return c
930176
public char readChar () throws KryoException {
		require(2);
		int p = position;
		position = p + 2;
		return (char)((buffer[p] & 0xFF) | ((buffer[p + 1] & 0xFF)) << 8);
	}
1225193
public static final int readUTF(DataInput in,
                                    char[] chars, int offset, int length,
                                    int bytesExpected)
        throws IOException
    {
        int c, c2, c3;

        int byteCount = 0;
        int charCount = 0;
        while (byteCount < bytesExpected && charCount < length) {
            c = in.readByte() & 0xff;
            switch (c >> 4) {
            case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
                // 0xxxxxxx
                byteCount++;
                chars[offset + charCount++] = (char)c;
                break;
            case 12: case 13:
                // 110x xxxx  10xx xxxx
                if ((byteCount += 2) > bytesExpected) {
                    throw new UTFDataFormatException();
                }
                c2 = in.readByte();
                if ((c2 & 0xc0) != 0x80) {
                    throw new UTFDataFormatException();
                }
                chars[offset + charCount++] =
                    (char)(((c & 0x1f) << 6) | (c2 & 0x3f));
                break;
            case 14:
                // 1110 xxxx  10xx xxxx  10xx xxxx
                if ((byteCount += 3) > bytesExpected) {
                    throw new UTFDataFormatException();
                }
                c2 = in.readByte();
                c3 = in.readByte();
                if ((c2 & 0xc0) != 0x80 || (c3 & 0xc0) != 0x80) {
                    throw new UTFDataFormatException();
                }
                chars[offset + charCount++] = (char)(((c & 0x0f) << 12) |
                                                     ((c2 & 0x3f) << 6) |
                                                     (c3 & 0x3f));
                break;
            default:
                // 10xx xxxx,  1111 xxxx
                throw new UTFDataFormatException();
            }
        }

        return charCount;
    }