code: private int parseUtf8(InputStream is, int length)
      throws IOException
    {
      if (length <= 0)
        return 0;
      
      if (length > 256) {
        is.skip(length);
        return 0;
      }
      
      int offset = _charBufferOffset;
      
      if (_charBuffer.length <= offset + length) {
        char []buffer = new char[2 * _charBuffer.length];
        System.arraycopy(_charBuffer, 0, buffer, 0, _charBuffer.length);
        _charBuffer = buffer;
      }
      
      char []buffer = _charBuffer;
      boolean []isJavaIdentifier = IS_JAVA_IDENTIFIER;
      boolean isIdentifier = true;
      
      while (length > 0) {
        int d1 = is.read();
        
        char ch;
  
        if (d1 == '/') {
          ch = '.';
          
          length--;
        }
        else if (d1 < 0x80) {
          ch = (char) d1;
          
          length--;
        }
        else if (d1 < 0xe0) {
          int d2 = is.read() & 0x3f;
  
          ch = (char) (((d1 & 0x1f) << 6) + (d2));
          
          length -= 2;
        }
        else if (d1 < 0xf0) {
          int d2 = is.read() & 0x3f;
          int d3 = is.read() & 0x3f;
  
          ch = (char) (((d1 & 0xf) << 12) + (d2 << 6) + d3);
          
          length -= 3;
        }
        else
          throw new IllegalStateException();
        
        if (isIdentifier && isJavaIdentifier[ch]) {
          buffer[offset++] = ch;
        }
        else {
          isIdentifier = false;
        }
      }
      
      if (! isIdentifier)
        return 0;
  
      int charLength = offset - _charBufferOffset;
      
      _charBufferOffset = offset;
      
      return charLength;
    }
docs: Parses the UTF.