4 ms·
Even Windows-format ASCII isn't fixed width - CR-LF is a two-byte 'codepoint'...
by jameshart 13y ago
Even Windows-format ASCII isn't fixed width - CR-LF is a two-byte 'codepoint'...
- nitrogen 13y agoYou can think of it as two separate instructions, CR to move horizontally to the beginning of the line, and LF to move down by one line.
- zorked 13y agoNot really because a single CR or LF does not do a real CR or LF.
- prewett 13y agoIt used to, back in The Day, when you had hard-copy consoles or even dot matrix printers. I think sending CR (but not LF) and then printing accents over top of the original line was a way of printing some European languages with just ASCII.
- barrkel 13y ago$ man terminfo | grep cursor_down | head -1 cursor_down cud1 do down one line $ tput cud1 | hexdump -C | cut -f 1-20 | head -1 00000000 0a |.| $ man terminfo | grep carriage_return | head -1 carriage_return cr cr carriage return (P*) $ tput cr | hexdump -C | cut -f 1-20 | head -1 00000000 0d |.| If you ever write a bash script that does more advanced things with the terminal, you'll get familiar with tput, termcap and terminfo pretty quickly.
- kps 13y agoIt does in ASCII, and (consequently) in any ANSI-conforming terminal [emulator].
- jameshart 13y agoYou can think of it that way until you say, try to take the first n characters of a string and wind up with your string terminated with an orphaned CR without its accompanying LF. Outside of ANSI terminals, teletypes and and dot matrix printers, they really don't work like that any more. If they did you'd be able to substitute LFCR for CRLF, or use multiple LFs with a single CR to leave multiline gaps - and multiple CRs would be redundant. Try sending a CSV file with LFCR line-endings, or HTTP headers separated by CRCRCRCRLF... see if that works everywhere reliably. Also, CRLF would be an acceptable substitute everywhere for UNIX LF line-endings, but clearly it's not. Fact is, CRLF is a two-byte magic number in a lot of places.