Browsers read resources as Asian characters

While editing a local HTML file, Safari and Firefox refused to load the CSS and JS files.

Screenshot of odd characters

Solution

Using BBEdit, I converted the CSS and JS files from UTF-8 to UTF-16.

changing in BBEdit

Explanation

Not every character in a file may belong to the Roman alphabet. Unicode Transformation Forat (UTF)-based files use 16, 24 or 32 bytes (ones and zeros) to represent each character. In addition to the content itself, each file contains a Byte Order Mark (BOM), which tells computers what kind of data to expect. If the BOM says one thing (like “This file uses UTF-8 characters”) but the characters themselves use a different number of bytes, the result is gibberish.

Reference

Tags: problem solving research