docx-validate
    Preparing search index...

    Function decodeXmlPart

    • Decode a part's bytes and report the encoding they are in, so a caller that writes the part back can put it in the same encoding.

      The encoding is chosen exactly as decodeXmlBytes chooses it — the byte order mark first, then the XML declaration — with one difference: a declaration naming an encoding this project cannot decode makes this function return undefined instead of falling back to UTF-8. The caller must then leave such a part's bytes untouched: decoding them as UTF-8 replaces every byte the two encodings do not share, and writing that text back corrupts the part. The validators keep decodeXmlBytes' UTF-8 fallback and report the mismatch as an xml-encoding finding instead.

      Parameters

      • bytes: Uint8Array

      Returns DecodedXmlPart | undefined