Skip to content
uencoder

Byte Order Mark

The byte order mark (BOM) is the U+FEFF character placed at the start of Unicode text to indicate the encoding form and byte order.

Purpose

It lets a decoder auto-detect the text encoding and byte order without external metadata.

Mechanism

Different encodings produce different BOM byte sequences: UTF-8 = EF BB BF, UTF-16LE = FF FE, UTF-16BE = FE FF, UTF-32LE = FF FE 00 00, UTF-32BE = 00 00 FE FF. A decoder reads the first 2-4 bytes and matches them.

Use cases

  • Encoding detection in text editors
  • Cross-system text file exchange
  • Encoding identification for database imports
  • CSV file handling in Excel

Examples

  • Input
    UTF-16LE file
    Output
    FF FE ...

    Leading bytes FF FE indicate little-endian UTF-16

Common errors

Mistaking a UTF-8 BOM for data content
Detect and strip the BOM when reading

Related terms

Related tools

References