PAC-E013 · byte-order-mark

File saved as UTF-16 instead of UTF-8 or ASCII

medium · Errors and robustness

The file was saved as UTF-16 (Notepad's "Unicode" or Windows PowerShell output), not as UTF-8 or plain ASCII. Windows cannot load such a file, so Windows programs ignore it; in the checker it also shows up as a syntax error.

Why it matters

A PAC file is text, and the text has to be stored in an encoding that the engine reads. UTF-8 and plain 7-bit ASCII work everywhere. UTF-16 stores every character in two bytes and usually starts with the two-byte byte order mark FF FE. Windows editors and tools write it without asking: Notepad’s “Unicode” setting, and in Windows PowerShell 5 the > redirection and Out-File. In the lab on Windows 11 (2026-10-11) Windows could not load a PAC file saved as UTF-16, so every Windows program behaved as if there were no PAC file at all. A UTF-8 file loaded normally with or without the three-byte UTF-8 byte order mark, so that mark is not a problem.

The checker reads a file that you open in it as UTF-8. A UTF-16 file then turns into odd characters and a syntax error, and this rule names the cause. It recognises the file by its UTF-16 byte order mark; a UTF-16 file without one only shows up as the syntax error.

How to fix

Save the file as UTF-8 (or plain ASCII), e.g. in PowerShell with Set-Content -Encoding ascii or Out-File -Encoding utf8; check the first bytes with `hexdump -C file | head -1` (FF FE means UTF-16).

Examples

Bad

// (the file begins with the bytes FF FE, and every character is followed by a zero byte)
function FindProxyForURL(url, host) {
  return "DIRECT";
}
Open bad example in checker

Good

function FindProxyForURL(url, host) {
  return "DIRECT";
}
Open good example in checker

The bad example cannot be shown as text; the difference is in the bytes of the file.

Engine behaviour

EngineBehaviourSource
chromiumA UTF-8 file with a byte order mark loads normally; the mark is removed when the file is downloaded. A UTF-16 file was not tested.lab, verified 2026-10-04
winhttpA UTF-8 file with or without a byte order mark loads normally. A UTF-16 file and a gzip-compressed response fail to load; a Latin-1 file loads, but its non-ASCII characters are garbled.lab, verified 2026-10-11

Source: code = read in the engine's source, doc = vendor documentation, lab = observed in a lab run, expert = practitioner knowledge, not yet verified.

Related rules

References

Last updated: