# EPUBCheck HTM_058: HTML file saved as UTF-16, how to fix it

Source: https://epubcc.com/epubcheck/htm_058/ (updated 2026-11-04)

EPUBCheck HTM_058 is an error message: “HTML documents must be encoded in UTF-8, but UTF-16 was detected.” An HTML document is encoded in UTF-16, and EPUB's XHTML documents must be UTF-8. Some reading apps show garbled text or refuse to open a chapter in another encoding.

- Official message (EPUBCheck 5.4.0): HTML documents must be encoded in UTF-8, but UTF-16 was detected.
- Default severity: Error

## Typical causes

- A file saved in UTF-16 by a text editor, often called "Unicode" in Windows save dialogs.
- A conversion script that wrote its output with the system's default encoding.

## How to fix it

1. Open the file EPUBCheck names (the message gives the path, line and column) in a text or EPUB editor such as Sigil, or unzip the EPUB and open it there.
2. Re-save the file as UTF-8 (without a byte order mark if your editor offers the choice).
3. Make the XML declaration match: <?xml version="1.0" encoding="UTF-8"?>.
4. Rebuild the EPUB and run EPUBCheck again to confirm the message is gone.

## When it's not this

If the file is a stylesheet rather than a chapter, the encoding messages are CSS-003 and CSS-004.

## Sources

- EPUB 3.3, §6.1.2 XHTML requirements: https://www.w3.org/TR/epub-33/#sec-xhtml-req (read 2026-11-04)
- EPUBCheck 5.4.0 message texts (MessageBundle.properties, w3c/epubcheck on GitHub): https://github.com/w3c/epubcheck/blob/v5.4.0/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties (read 2026-11-04)

Message text and severity: EPUBCheck (W3C, BSD-3-Clause). Explanation: EpubCC.
