Search code examples
htmlunicodeutf-16byte-order-mark

How to add a BOM to an HTML document


From the W3C:

If an HTML document does not start with a BOM, and its encoding is not explicitly given by Content-Type metadata, and the document is not an iframe srcdoc document, then the character encoding used must be an ASCII-compatible character encoding

So How I can add a BOM which would mean the document is encoded in UTF16 for example?


Solution

  • The byte order mask is an hex sequence which can be put at the beginning of any file.
    It has nothing to do with the html/other web languages.

    An hex editor is a good way to add it.

    Although UTF-32 offer the advantage of fixed length encoding, some browser/e-mail client dropped the support for it.

    note: UTF-16 is mainly used on windows.