Name of CRLF

PhilipBrown

Active Member
Licensed User
Longtime User
I'm curious to know why the name CRLF was chosen for Chr(10), which is the Line Feed character.

I realise that in Linux you just need a Line Feed, and don't need the Carriage Return Chr(13) + Line Feed Chr(10) combination which is what Windows uses, but why the confusing name CRLF for Chr(10)? Why was it not just called LF?

I also realise it's too late to change the definition now, but other posts have shown that people are confused by the name, so what was the rational behind it?

Also how about adding new LF and CR constants, and let people decide if they want to use them? (Yes I also realise we can define our own ...)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
CRLF is the standard VB constant for an end of line character(s). The default end of line character in Android is chr(10). This is the reason for this constant.

CRLF should be the default end of line character used in Basic4android.

Note that I'm not sure that it was a correct decision to use this constant name...

Adding more constants will only make it more confusing. LF is the same as the (b4a) CRLF. CRLF cannot be change at this point. CR alone is never needed. So if you want to write a windows end of line then you should use chr(13) & chr(10).


Note that File.ReadList handles correctly both types of end of line characters.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
If we go back to the typewriter times.. there were two controls.. the knob at the right of the machine for line feed only, and the handle for the carriage return AND line feed together in one stroke. So I believe CRLF makes more sense to me, unless one wanted to go down to the next line without starting that line from the beginning!

my 2 cents!
 
Upvote 0

TomA

Active Member
Licensed User
Longtime User
CRLF goes back a long way.

Systems based on ASCII or a compatible character set use either LF (Line feed, 10 in decimal) or CR (Carriage return, 13 in decimal) individually, or CR followed by LF (CR+LF). These characters are based on printer commands: The line feed instructed the printer to advance the paper one line, and a carriage return indicated that the printer carriage should return to the beginning of the current line. If the printer was only fed a line feed, it would advance one line and continue printing from that position on the next line (no carriage return was performed). It was also possible to cause a printer to overprint on the same line by using the carriage return since the print position would then be returned to the start of the line without advancing the paper - an action sometimes used on line printers to create bold text. Some of the other functions used with the line printers were things like VT for Vertical Tab (to move down some distance) and FF for Form Feed (go to the top of the next page).

Actually, the fact that a chr(10) (LF) is all that is needed on many sytems is sometimes annoying since technically it is only a line feed and the cursor should not go to the beginning of the next line without the chr(13) (CR). This can make it hard to format something where you just want to go to the next line but keep the cursor in the same position relative to the beginning of the line.

(And for anyone that doesn't know what a line printer is, they were commonly used on early computers and printed text a complete line at a time - at speeds of anywhere from 150 lines per minute to 2400 lines per minute and up - don't remember what the upper speed limit of these, 2400 was the fastest I ever worked with.)
 
Upvote 1

TomA

Active Member
Licensed User
Longtime User
One additional comment on CRLF

If you go to the various internet protocol documents, such as RFC 0821 (SMTP), RFC 1939 (POP), RFC 2060 (IMAP), or RFC 2616 (HTTP), you'll see that they all specify CR+LF as the line termination sequence. So the the real question is not "Why do CP/M, MS-DOS, and Windows use CR+LF as the line terminator?" but rather "Why did other people choose to differ from these standards documents and use some other line terminator?"
 
Upvote 0
Top