JRS: In article <40**************@PointedEars.de>, seen in
news:comp.lang.javascript, Thomas 'PointedEars' Lahn
<Po*********@web.de> posted at Wed, 7 Apr 2004 20:57:39 :
Pierre wrote:
I have recently bought the book: JavaScript & DHTML Cookbook. As I
opened the .js files with note pad, I asked myself why was the code
formated in such a way. The code looks as if it had been produced by
some kind of programs instead of a person. I also noticed a lot of
little squared zeros; what are those all about?
The file is likely to have been saved under UNIX, a UNIX derivative
(short: *n*x, e.g. GNU/Linux) or under MacOS (Apple Macintosh).
Those operating systems use different newline delimiters than Windows
(Windows: \r\n; Unix: \n; Mac: \r). Notepad is unable to read the
UNIX and Mac format (thus displayes the "squared zeroes" for those
undisplayable control characters), use an editor that is capable, like
metapad (freeware) or UltraEdit (shareware). If you have installed
Cygwin or have (SSH/Telnet) access to a *n*x system, you can also use
the `unix2dos' program (a `recode' wrapper) on those files.
Another possibility is that the code has been "line-optimized" or
"uglified" (which is bad for a tutorial); you can use a JavaScript
beautifier to make it readable. Ask Google about "JavaScript formatter".
In attempting to give a complete explanation, Pointy-Head has again
demonstrated limits of his experience by giving only a partial answer.
A full answer would be encyclopaedic; but an adequate answer would be
more useful.
WordPad - at least in Win98 - transforms both CR & LF endings to CRLF;
given that Notepad is available, WordPad could well be the best
solution.
MiniTrue, for DOS-16, Win32, UNIX, has line-end correction as an example
(and is a very useful tool in general, and so worth fetching, for those
who can operate at the command-line).
The stated conditions for UNIX2DOS are unnecessarily limited; it is
*IIRC* distributed with other software, and one can surely get it over
the Net from FTP archives such as Garbo.
It is better not to fully reformat code provided as an example if there
is any prospect of the associated material referring to it in a layout-
dependent manner,
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/> Update hope?