docs: 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;
      }