Search code examples
escapingspecial-charactershistorylanguage-designcontrol-characters

Why is there an escape sequence for VERTICAL TAB?


Another question, What is a vertical tab?, describes what the vertical tab character was originally used for.

But why was U+000B VERTICAL TAB considered important enough to be allocated an escape sequence ('\v') in the first place, in C and many other programming languages?

See also: some guy complaining about this.


Solution

  • It's possible that when C was created, it was expected that the vertical tab and bell characters were expected to be sufficiently useful as delimiters within code that would be ported between ASCII and EBCDIC that code had to provide a readable and portable way of notating them. Although one could write

    #define QVTAB "\013"
    printf("Field1" QVTAB "Field2");

    I don't think such usage was legal in the earliest dialects of C. Further, even if such usage is permitted, using special macros for quoted version of characters would probably have been considered a little ugly. I know such things ended up being necessary in printf portable-type format specifiers, but that doesn't mean it's pretty.

    Another thing to consider is that C was not desgined to be a programming language that people would use in the decades to come. It was designed to solve some immediate needs. K&R wouldn't have cared about whether anyone would want VTAB characters after the 1970's; if their immediate customers would have use for them, that was a perfectly good reason to include them.