code: private String parseTextDecl(String encoding) throws SAXException,
              IOException {
          String encodingName = null;
          int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF;
  
          // Read an optional version.
          if (tryRead("version")) {
              String version;
              parseEq();
              checkLegalVersion(version = readLiteral(flags));
              if (!version.equals("1.0")) {
                  if (version.equals("1.1")) {
                      fatal("XML 1.1 not supported."); // 2006-04-24 hsivonen
                  } else {
                      fatal("illegal XML version", version, "1.0"); // removed
                      // 1.1 --
                      // 2006-04-24
                      // hsivonen
                  }
              }
              requireWhitespace();
          }
  
          // Read the encoding.
          require("encoding");
          parseEq();
          encodingName = readLiteral(flags);
          checkEncodingLiteral(encodingName); // 2006-04-28 hsivonen
          if (reader == null) {
              draconianInputStreamReader(encodingName, is, true);
          } else {
              checkEncodingMatch(encoding, encodingName);
          }
          skipWhitespace();
          require("?>");
  
          return encodingName;
      }
docs: Parse a text declaration.
  
  <pre>
  [79] TextDecl ::= '&lt;?xml' VersionInfo? EncodingDecl S? '?&gt;'
  [80] EncodingDecl ::= S 'encoding' Eq
  ( '&quot;' EncName '&quot;' | &quot;'&quot; EncName &quot;'&quot; )
  [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
  </pre>
  
  <p>
  (The <code>&lt;?xml</code>' and whitespace have already been read.)
  
  @return the encoding in the declaration, uppercased; or null
  @see #parseXMLDecl
  @see #setupDecoding