ruby-changes:39793
From: knu <ko1@a...>
Date: Wed, 16 Sep 2015 15:03:31 +0900 (JST)
Subject: [ruby-changes:39793] knu:r51874 (trunk): [DOC] Document the full list of supported escape sequences in string literals
knu 2015-09-16 15:03:18 +0900 (Wed, 16 Sep 2015) New Revision: 51874 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51874 Log: [DOC] Document the full list of supported escape sequences in string literals Modified files: trunk/ChangeLog trunk/doc/syntax/literals.rdoc Index: doc/syntax/literals.rdoc =================================================================== --- doc/syntax/literals.rdoc (revision 51873) +++ doc/syntax/literals.rdoc (revision 51874) @@ -83,8 +83,31 @@ Any internal <tt>"</tt> must be escaped: https://github.com/ruby/ruby/blob/trunk/doc/syntax/literals.rdoc#L83 "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, -<tt>\t</tt> for tab, etc. +Double-quote strings allow escaped characters such as <tt>\n</tt> for +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 <tt>#{...}</tt>: Index: ChangeLog =================================================================== --- ChangeLog (revision 51873) +++ ChangeLog (revision 51874) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Sep 16 14:55:33 2015 Akinori MUSHA <knu@i...> + + * 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@r...> * string.c (rb_str_setbyte): keep the code range as possible. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/