I encountered the following error in FireBug (FireFox) on jQuery’s ui.core.js that halts execution of the rest of my scripts:

illegal character

Illegal Character error in Firebug

Illegal Character error in Firebug

The last time I encountered this problem, I renamed the file a few times and that fixed it. Yes, that makes no sense but as long as it was fixed, I just went about my merry self until it happened again today, and no amount of file renaming would fix it. So I did a little bit of investigation to figure out exactly why this happened.

First, I found this problem only happening in Firefox, and not Chrome, or IE.

When accessing the file directly in the browser, the first 3 chars were:


/*
*
*
*
*
*/

(function($) {

cURL returned the same result, narrowing it down to either the server adding that character, or the file containing it. Since the server is JBoss, it’s most likely the file.

Opening the file in Binary mode in Textpad, I found that the first 3 bytes had the hex value: EF BB BF

This has to be a standard hex header for a certain file format (probably unicode related?) So I googled for that hex value. The first result was a wikipedia entry for Byte-order mark. This made total sense already. The Byte-order mark specifies the byte order (endianness) of the file that follows, with relation to unicode-related encodings. It turns out that EF BB BF is the Byte-order mark to denote UTF-8, but at the same time, it is completely unnecessary as UTF-8 has no byte-order issues by design.

So I had to get notepad++ to remove the first 3 bytes of that file, by choosing the option for “Encode in UTF-8 without BOM” in the Format Menu.

This fixed the issue! I hope this helps others that encounter this completely obscure looking error.

Discussion

  1. it also helps, if u yust open file in notepad and save as !!! ENCODING: Unicode or Unicode big ndian or UTF-8 !!!
    (and NOT ANSI)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Made by Themes Kult