Line endings and Javascript problems

Discussion about BCA's Internet Hosting Service
User avatar
David Gibson
DG test
Posts: 603
Joined: Thu 16 Mar 2006 23:45

Line endings and Javascript problems

Post by David Gibson » Sat 28 Feb 2009 15:58

Here's another weird problem I have had, trying to get the BCRA web pages to run on the new server...

One particular page threw up the annoyingly vague JavaScript "syntax error" when I tried to run it on BCA's new server. It was fine on the old server, and on localhost.

I eventually realised that - for what reason I do not know - it had been created with MAC-style line endings (i.e. hex 0D). when I converted these to PC-style (0D0A) it ran without error. (Perhaps Unix-style line endings of 0A would also have worked? - let's just see: yes they do work).

The syntax error was caused because JavaScript was expecting to see a line ending, and didnt.

Im assuming - guessing - that the old server I was running the BCRA site on ws either Windows-based or had some property set somewhere to map line endings.

User avatar
David Gibson
DG test
Posts: 603
Joined: Thu 16 Mar 2006 23:45

Re: Line endings and Javascript problems

Post by David Gibson » Wed 08 Apr 2009 12:05

David Gibson wrote:when I converted these to PC-style (0D0A) it ran without error.
reminder to myself: use WildEdit. Search for regexp \r([^\n]) and replace with \r\n$1 in files *.html

Post Reply