ASCII is a subset of UTF-8. You can read any ASCII-encoded document as UTF-8, and it will work. ASCII only uses 7 bits, and UTF-8 uses the unused eight bit to mark non-ASCII code units.
The XML spec has an informal algorithm for detecting the encoding which is necessary to read the
<?xml declaration, if one is present. An encoding might also be implied by a Byte Order Mark at the beginning of the document.
If no encoding information is present in the document, you may have encoding information from a transport protocol, e.g. HTTP or MIME. Then use that.
But the default assumption is UTF-8. Citing the XML 1.0 and XML 1.1 spec:
In the absence of information provided by an external transport protocol […], it is a fatal error […] for an entity which begins with neither a Byte Order Mark nor an encoding declaration to use an encoding other than UTF-8. Note that since ASCII is a subset of UTF-8, ordinary ASCII entities do not strictly need an encoding declaration.
Something that appears to be encoded in UTF-8 and only uses the ASCII-compatible subset in the beginning might actually be encoded in any other ASCII-compatible encoding, such as an encoding in the ISO 8859 family (e.g. Latin-9). So you still need to determine the proper encoding through encoding declarations, BOMs, or transport metadata. Do not try to sniff the encoding. If the encoding does not match the actual contents, that's an error and you must not process the malformed document.