Decode UTF-16LE and UTF-16BE Base64 when text contains NUL bytes
Encode the same Latin and Korean characters in both byte orders. Use their code units to choose the correct setting even when the sample has no BOM.
Group the bytes in pairs
The code units for A and 가 are 0041 and AC00. Little-endian UTF-16 stores the low byte of each pair first. Big-endian UTF-16 stores the high byte first. ASCII-heavy UTF-16 data read as UTF-8 often shows unexpected NUL characters.
Restore the same two characters twice
Paste the first Base64 sample into Decodex and select UTF-16LE as the source encoding. Use UTF-16BE for the second sample. Each gives A가 with its matching setting. Both samples omit the BOM so you can see the byte order without that extra marker.
| Input | Bytes in hexadecimal | Base64 |
|---|---|---|
A가 · UTF-16LE | 41 00 00 AC | QQAArA== |
A가 · UTF-16BE | 00 41 AC 00 | AEGsAA== |
Resolve an ambiguous file
For a file known to be UTF-16, an initial FF FE identifies little-endian order and FE FF identifies big-endian order. Without a BOM, consult the producer or check a known word. Runs of zero bytes also occur in binary formats, so they are only a clue.