On a typewriter, a new line is carried out by two actions. The print position goes to the beginning of the line (Carriage Return) and the print position moves and down to the next line (Line Feed). When systems for character sets were developed for computers, these character sets got control characters for both, the carriage return as well as the line feed. How a new line is actually encoded in a modern text file and which of these control characters are used differs from system to system. An overview, you can see in the next table.
|CR LF||0D 0A / 13 10||ASCII Windows, DOS, OS/2, TOS Atari, CP/M|
|LF||0A / 10||ASCII Unix, Linux, Mac OS X, BSD, AmigaOS|
|CR||0D / 13||ASCII Mac OS bis Version 9, Apple II|
|NEL||15 / 21||EBCDIC AIX OS, OS/390|
|FF||U+000C||Unicode Form Feed|
|NEL||U+0085||Unicode New Line|
|LS||U+2028||Unicode Line Separator|
|PS||U+2029||Unicode Paragraph Separator|
As you can see, the Line Feed (LF) has the code 0A in the ASCII character set and the Carriage Return (CR) is encoded with 0D. Windows or DOS are using both characters CR LF as a line break, Unix, Linux or Mac OS X only LF and Mac OS up to version 9 only CR. Behind those characters, the Unicode standard also defines the other code points shown in this table as code points for a new line.
The different encodings for line breaks are producing lots of problems when interchanging files between different systems. A file created on a Linux system seems to have no line breaks on Windows, because Windows is using another character for a line break than Linux has written to the file. To make this file readable on the Windows system, it is necessary to change the character used as a new line.
Rewriting Line Breaks
If you want to read files from other systems with other line breaks on your system, you can rewrite the line breaks used in the file to the character for a line break of your system. This can be carried out with a great number of files at once with the software TextEncoder very easily and comfortably. Simply proceed as follows:
- Drag any files you want to change onto the Text Encoder.
- On the right side of the main window under "Line Breaks", under "Save as" select your desired line break, for example CRLF - Windows.
- In the lower right corner of the main window, you will find the storage options. Here you determine whether you want to overwrite the original file or if you want to save the converted file as a new file. For example, in a new folder.
- Finally, click on the "Convert" button. This changes the line break of all added files.
If you want to automate changing the line break of many files using a script, you can use the TextEncoder in the TextEncoder Pro CL version.
Change line breaks with the Text Converter
Also with the program Text Converter it is possible to change the used line breaks of text files. First of all, open the file or the files with the TextConverter. You can simply drag and drop the files or complete folders on the software. After that, you choose the action "Line Breaks" on the right side of the main program. Generally, the old line break of your file will be detected automatically, so that you only have to choose the new line break for your file. For example, you can choose "CRLF - Windows" and files from Linux or Mac will be readable on Windows. Of course, with the program, it is also possible to go the other way around. You can also change the Windows line break to any other line break of another system.
The Text Converter is also available as a batch version that can be controlled and automated via the command line or via a script.