Skip to content
EPUBCheck · XHTML content documents

EPUBCheck HTM_058: HTML file saved as UTF-16

Updated:

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.

The official message

HTML documents must be encoded in UTF-8, but UTF-16 was detected.

Default severity
Error. The EPUB breaks a rule of the specification and is invalid. Stores and Send to Kindle may reject it, and EPUBCheck exits with status 1.
EPUBCheck version
5.4.0

EPUBCheck prints this ID with an underscore instead of a hyphen; this page uses the ID exactly as EPUBCheck reports it.

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.

Terms used here

Other HTM messages

  • HTM_057 Viewport "…" value must be a positive number or the keyword "device-…"
  • HTM_059 Viewport "…" property must not be defined more than once, but found values […].
  • HTM_056 Viewport metadata has no "…" dimension (both "width" and "height" properties are required)
  • HTM_060b EPUB reading systems must ignore viewport meta elements in reflowable documents; viewport declaration "…" will be ignored.
  • HTM_055 The "…" element should not be used (discouraged construct)
  • HTM_061 "…" is not a valid custom data attribute (it must have at least one character after the hyphen, be XML-compatible, and not contain ASCII uppercase letters).

Sources

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

FAQ

What does EPUBCheck HTM_058 mean?

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.

Is HTM_058 an error?

HTM_058 is reported as error by default. The EPUB breaks a rule of the specification and is invalid. Stores and Send to Kindle may reject it, and EPUBCheck exits with status 1.