-1

I have one big file that consists of HMTL, Javascript and CSS and I wish to split it up to make it more managable. But when I split the HTML file up and save it as seperate HTML, Javascript and CSS files I get the error :

Uncaught SyntaxError: Unexpected token ILLEGAL

When I click on the error it takes me to the file in the browser and my file consists of only Chinese symbols.

I have tried finding the answer and apparently I have hidden characters in my code but how am I meant to find these ?

What can I do to fix this issue ?

rekoDolph
  • 813
  • 1
  • 9
  • 31

1 Answers1

0

Mojibake like this can occur when the program reading in a file is unable to figure out what kind of encoding a file is using and guesses the encoding incorrectly. It could be that you have a weird character lurking in your file somewhere that is completely throwing off the encoding detection.

Some encoding schemes provide a way to mitigate this problem by using a BOM, which is a short marker at the beginning of the file that indicates the type of encoding that the file uses. BOMs have advantages and disadvantages, but one big advantage is that they firmly establish a file's encoding so that the program loading the file doesn't have to guess what the encoding is. It sounds like including the BOM in your file remedied your issue.

For more information on encoding, see:

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

JLRishe
  • 99,490
  • 19
  • 131
  • 169