Difference between revisions of "LINE END CRLF"

From ThoughtBridges
Jump to: navigation, search
(Created page with "=Line Endings= Code: <code>LINE_END_CRLF</code> (with two underscore characters) ==For Graphics Designers== Different operating systems favor different conventions to deter...")
 
(For Graphics Designers)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
 
=Line Endings=
 
=Line Endings=
  
Code: <code>LINE_END_CRLF</code> (with two underscore characters)
+
Metapattern Code: <code>LINE_END_CRLF</code> (with two underscore characters)
  
 
==For Graphics Designers==
 
==For Graphics Designers==
Line 9: Line 9:
 
If no attention is paid to this issue, you might end up with script files that look like gobbledygook when opened in Notepad on Windows.
 
If no attention is paid to this issue, you might end up with script files that look like gobbledygook when opened in Notepad on Windows.
  
If this metapattern was applied by the software developer, the script file (the file with the .jsx extension) will have carriage return + line feed line (CR+LF) endings.  
+
If the LINE_END_CRLF metapattern was applied by the software developer, the script file (often a file with a .jsx or .js file name extension) will use carriage return + line feed (CR+LF) line endings.  
  
 
Carriage return and line feed are two special ‘codes’ that can be inserted between the bytes that compose the text of the script.
 
Carriage return and line feed are two special ‘codes’ that can be inserted between the bytes that compose the text of the script.
  
Linux and Mac OS X normally use just a line feed character (numeric character code 10 in ASCII and Unicode) as the line ending.  
+
* Linux and Mac OS X normally use just a line feed character (numeric character code 10 in ASCII and Unicode) as the line ending.  
  
Mac OS (pre Mac OS X) uses a carriage return (numeric character code 13 in ASCII and Unicode).  
+
* Mac OS (pre Mac OS X) uses a carriage return (numeric character code 13 in ASCII and Unicode).  
  
Windows uses a combination of two consecutive codes: carriage return followed by line feed (numeric character code 10 followed by code 13 in ASCII and Unicode)
+
* Windows uses a combination of two consecutive codes: carriage return followed by line feed (numeric character code 10 followed by code 13 in ASCII and Unicode)
  
 
Luckily, most modern text editors are smart about this, and graciously handle text file with the ‘wrong’ line endings.
 
Luckily, most modern text editors are smart about this, and graciously handle text file with the ‘wrong’ line endings.
Line 35: Line 35:
 
In TextWrangler on Mac OS X, use the ‘File - Save As...’ menu item and make sure the ‘Line Breaks’ popup is set to ‘Windows (CRLF)’.
 
In TextWrangler on Mac OS X, use the ‘File - Save As...’ menu item and make sure the ‘Line Breaks’ popup is set to ‘Windows (CRLF)’.
  
In Notepad++ on Windows, use  
+
In Notepad++ on Windows, use
  
 
== For Software Developers ==
 
== For Software Developers ==

Latest revision as of 01:33, 6 April 2017

Line Endings

Metapattern Code: LINE_END_CRLF (with two underscore characters)

For Graphics Designers

Different operating systems favor different conventions to determine what constitutes the end of a line in a text file.

If no attention is paid to this issue, you might end up with script files that look like gobbledygook when opened in Notepad on Windows.

If the LINE_END_CRLF metapattern was applied by the software developer, the script file (often a file with a .jsx or .js file name extension) will use carriage return + line feed (CR+LF) line endings.

Carriage return and line feed are two special ‘codes’ that can be inserted between the bytes that compose the text of the script.

  • Linux and Mac OS X normally use just a line feed character (numeric character code 10 in ASCII and Unicode) as the line ending.
  • Mac OS (pre Mac OS X) uses a carriage return (numeric character code 13 in ASCII and Unicode).
  • Windows uses a combination of two consecutive codes: carriage return followed by line feed (numeric character code 10 followed by code 13 in ASCII and Unicode)

Luckily, most modern text editors are smart about this, and graciously handle text file with the ‘wrong’ line endings.

Notepad on Windows is an exception: it will only work well with carriage return + line feed line endings.

Notepad++ (http://notepad-plus-plus.org) is smart enough to handle this properly.

The idea is to standardize on a line ending that has the best chance of being interpreted correctly.

By using carriage return + line feed as the 'standardized' line ending, the file will show correctly in most circumstances.

It will work in Notepad on Windows (dumb program) and it will work in TextWrangler or BBEdit on Mac OS X (smart program); the same applies to the most common text editors in use.

If you have a script file that has the LINE_END_CRLF metapattern applied, and you need to re-save it, make sure you re-save it correctly so the line endings are respected.

In TextWrangler on Mac OS X, use the ‘File - Save As...’ menu item and make sure the ‘Line Breaks’ popup is set to ‘Windows (CRLF)’.

In Notepad++ on Windows, use

For Software Developers

Once your script is complete, make sure you save it with CRLF line endings.

To avoid the line ending changing during the download process, it is best to store your script in an archive file of sorts.

ZIP archives are best supported - they can be used both on Mac and on Windows.

By storing your file into a ZIP archive, the line endings will not be disrupted by the download process.

Detailed description of the metapattern

The script file uses carriage return + line feed line endings (Windows line endings).

Related metapatterns

 ZIP
 REGULAR_TABS