mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[DOC] Document the full list of supported escape sequences in string literals
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
965d8241c1
commit
d23857e558
2 changed files with 30 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Sep 16 14:55:33 2015 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* doc/syntax/literals.rdoc (Strings): [DOC] Document the full list
|
||||||
|
of supported escape sequences in string literals.
|
||||||
|
|
||||||
Wed Sep 16 14:49:58 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Sep 16 14:49:58 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (rb_str_setbyte): keep the code range as possible.
|
* string.c (rb_str_setbyte): keep the code range as possible.
|
||||||
|
|
|
@ -83,8 +83,31 @@ Any internal <tt>"</tt> must be escaped:
|
||||||
|
|
||||||
"This string has a quote: \". As you can see, it is escaped"
|
"This string has a quote: \". As you can see, it is escaped"
|
||||||
|
|
||||||
Double-quote strings allow escaped characters such as <tt>\n</tt> for newline,
|
Double-quote strings allow escaped characters such as <tt>\n</tt> for
|
||||||
<tt>\t</tt> for tab, etc.
|
newline, <tt>\t</tt> for tab, etc. The full list of supported escape
|
||||||
|
sequences are as follows:
|
||||||
|
|
||||||
|
\0 null, ASCII 00h (NUL)
|
||||||
|
\a bell, ASCII 07h (BEL)
|
||||||
|
\b backspace, ASCII 08h (BS)
|
||||||
|
\t horizontal tab, ASCII 09h (TAB)
|
||||||
|
\n newline (line feed), ASCII 0Ah (LF)
|
||||||
|
\v vertical tab, ASCII 0Bh (VT)
|
||||||
|
\f form feed, ASCII 0Ch (FF)
|
||||||
|
\r carriage return, ASCII 0Dh (CR)
|
||||||
|
\e escape, ASCII 1Bh (ESC)
|
||||||
|
\s space, ASCII 20h (SPC)
|
||||||
|
\\ backslash, \
|
||||||
|
\nnn octal bit pattern, where nnn is 1-3 octal digits ([0-7])
|
||||||
|
\xnn hexadecimal bit pattern, where nn is 1-2 hexadecimal digits ([0-9a-fA-F])
|
||||||
|
\unnnn Unicode character, where nnnn is exactly 4 hexadecimal digits ([0-9a-fA-F])
|
||||||
|
\u{nnnn ...} Unicode character(s), where each nnnn is 1-6 hexadecimal digits ([0-9a-fA-F])
|
||||||
|
\cx or \C-x control character, where x is an ASCII printable character
|
||||||
|
\M-x meta character, where x is an ASCII printable character
|
||||||
|
\M-\C-x meta control character, where x is an ASCII printable character
|
||||||
|
|
||||||
|
Any other charater followed by a backslash is interpreted as the
|
||||||
|
character itself.
|
||||||
|
|
||||||
Double-quote strings allow interpolation of other values using
|
Double-quote strings allow interpolation of other values using
|
||||||
<tt>#{...}</tt>:
|
<tt>#{...}</tt>:
|
||||||
|
|
Loading…
Add table
Reference in a new issue