int readChar() throws IOException {
  int ch=read();
  if (ch == '<' || ch < 0) {
    _peek=ch;
    return -1;
  }
  if (ch == '&') {
    ch=read();
    if (ch == '#') {
      ch=read();
      if (ch >= '0' && ch <= '9') {
        int v=0;
        for (; ch >= '0' && ch <= '9'; ch=read()) {
          v=10 * v + ch - '0';
        }
        if (ch != ';')         throw error("expected ';' at " + (char)ch);
        return (char)v;
      }
 else       throw error("expected digit at " + (char)ch);
    }
 else {
      _entityBuffer.setLength(0);
      for (; ch >= 'a' && ch <= 'z'; ch=read())       _entityBuffer.append((char)ch);
      String entity=_entityBuffer.toString();
      if (ch != ';')       throw expectedChar("';'",ch);
      if (entity.equals("amp"))       return '&';
 else       if (entity.equals("apos"))       return '\'';
 else       if (entity.equals("quot"))       return '"';
 else       if (entity.equals("lt"))       return '<';
 else       if (entity.equals("gt"))       return '>';
 else       throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `"+ (char)ch+ "'");
    }
  }
 else   if (ch < 0x80)   return (char)ch;
 else   if ((ch & 0xe0) == 0xc0) {
    int ch1=read();
    int v=((ch & 0x1f) << 6) + (ch1 & 0x3f);
    return (char)v;
  }
 else   if ((ch & 0xf0) == 0xe0) {
    int ch1=read();
    int ch2=read();
    int v=((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f);
    return (char)v;
  }
 else   throw new BurlapProtocolException("bad utf-8 encoding");
}

int readChar ( ) throws IOException { int ch = read ( ) ; if ( ch == '<' || ch < 0 ) { _peek = ch ; return - 1 ; } if ( ch == '&' ) { ch = read ( ) ; if ( ch == '#' ) { ch = read ( ) ; if ( ch >= '0' && ch <= '9' ) { int v = 0 ; for ( ; ch >= '0' && ch <= '9' ; ch = read ( ) ) { v = 10 * v + ch - '0' ; } if ( ch != ';' ) throw error ( "expected ';' at " + ( char ) ch ) ; return ( char ) v ; } else throw error ( "expected digit at " + ( char ) ch ) ; } else { _entityBuffer . setLength ( 0 ) ; for ( ; ch >= 'a' && ch <= 'z' ; ch = read ( ) ) _entityBuffer . append ( ( char ) ch ) ; String entity = _entityBuffer . toString ( ) ; if ( ch != ';' ) throw expectedChar ( "';'" , ch ) ; if ( entity . equals ( "amp" ) ) return '&' ; else if ( entity . equals ( "apos" ) ) return '\'' ; else if ( entity . equals ( "quot" ) ) return '"' ; else if ( entity . equals ( "lt" ) ) return '<' ; else if ( entity . equals ( "gt" ) ) return '>' ; else throw new BurlapProtocolException ( "unknown XML entity &" + entity + "; at `" + ( char ) ch + "'" ) ; } } else if ( ch < 0x80 ) return ( char ) ch ; else if ( ( ch & 0xe0 ) == 0xc0 ) { int ch1 = read ( ) ; int v = ( ( ch & 0x1f ) << 6 ) + ( ch1 & 0x3f ) ; return ( char ) v ; } else if ( ( ch & 0xf0 ) == 0xe0 ) { int ch1 = read ( ) ; int ch2 = read ( ) ; int v = ( ( ch & 0x0f ) << 12 ) + ( ( ch1 & 0x3f ) << 6 ) + ( ch2 & 0x3f ) ; return ( char ) v ; } else throw new BurlapProtocolException ( "bad utf-8 encoding" ) ; }
reads a character from the underlying stream .
