manpagez: man pages & more
info octave
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Escape Sequences in string constants

In double-quoted strings, the backslash character is used to introduce escape sequences that represent other characters. For example, ‘\n’ embeds a newline character in a double-quoted string and ‘\"’ embeds a double quote character. In single-quoted strings, backslash is not a special character. Here is an example showing the difference:

toascii ("\n")
    ⇒ 10
toascii ('\n')
    ⇒ [ 92 110 ]

Here is a table of all the escape sequences used in Octave (within double quoted strings). They are the same as those used in the C programming language.


Represents a literal backslash, ‘\’.


Represents a literal double-quote character, ‘"’.


Represents a literal single-quote character, ‘'’.


Represents the “nul” character, control-@, ASCII code 0.


Represents the “alert” character, control-g, ASCII code 7.


Represents a backspace, control-h, ASCII code 8.


Represents a formfeed, control-l, ASCII code 12.


Represents a newline, control-j, ASCII code 10.


Represents a carriage return, control-m, ASCII code 13.


Represents a horizontal tab, control-i, ASCII code 9.


Represents a vertical tab, control-k, ASCII code 11.

In a single-quoted string there is only one escape sequence: you may insert a single quote character using two single quote characters in succession. For example,

'I can''t escape'
    ⇒ I can't escape

© 2000-2018
Individual documents may contain additional copyright information.