Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Escape sequences

So I was reading some topics and found over the lua manual this:

\a  bell
\b  back space
\f  form feed
\n  newline
\r  carriage return
\t  horizontal tab
\v  vertical tab
\\  backslash
\"  double quote
\'  single quote
\[  left square bracket
\]  right square bracket

I'l like to know what: \a, \b, \f \r, \t and \v do. It's interesting.


  • dave1707dave1707 Mod
    Posts: 7,469

    @TokOut Those are old teletype commands that got carried forward.

    The \a rang a bell to let you know something was starting to print or ending. 
    The \b moved the print head one character to the left. 
    The \f moved the paper up one line.
    The \r moved the print head all the way left.
    The \t moved the print head some character amount to the right.
    The \v moved the print head in a vertical position some number of lines.
  • Posts: 808

    Thank you! Us very interesting. Also why didn't they in Lua mention \{unicode}

  • em2em2
    Posts: 194

    In the lua 5.3 manual:

    We can specify any byte in a short literal string by its numeric value (including embedded zeros). This can be done with the escape sequence \xXX, where XX is a sequence of exactly two hexadecimal digits, or with the escape sequence \ddd, where ddd is a sequence of up to three decimal digits. (Note that if a decimal escape sequence is to be followed by a digit, it must be expressed using exactly three digits.)

    The UTF-8 encoding of a Unicode character can be inserted in a literal string with the escape sequence \u{XXX} (note the mandatory enclosing brackets), where XXX is a sequence of one or more hexadecimal digits representing the character code point.

Sign In or Register to comment.