mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 51871,51872,51874,51875,51876,51877,51878,57517: [Backport #13190]
* doc/syntax/literals.rdoc (Strings): mention about ?a literal. literals.rdoc: fix typos * doc/syntax/literals.rdoc (Strings): fix typos. * doc/syntax/literals.rdoc (Strings): [DOC] Document the full list of supported escape sequences in string literals. * doc/syntax/literals.rdoc (Strings): [DOC] Revise the character literal part. literals.rdoc: add DEL [ci skip] * doc/syntax/literals.rdoc (Strings): [DOC] add DEL. [DOC] `\0` is interpreted as NUL only if not followed by an octal digit. [DOC] Remove `\0` since it's aprt of octal notation A typo is fixed while at it. doc: Fix error for escape sequences in string literals Backslash goes first in escape sequences, so it must be "any other character following a backslash is interpreted as ...", while the doc says "...followed by...". Author: Marcus Stollsteimer <sto.mar@web.de> [ruby-core:79418] [Bug #13190] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fd69ec05c0
commit
ed20b2561c
3 changed files with 59 additions and 3 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Sun Mar 26 02:44:16 2017 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* doc/syntax/literals.rdoc (Strings): [DOC] Revise the character
|
||||
literal part.
|
||||
|
||||
Sun Mar 26 02:44:16 2017 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* doc/syntax/literals.rdoc (Strings): [DOC] Document the full list
|
||||
of supported escape sequences in string literals.
|
||||
|
||||
Sun Mar 26 02:44:16 2017 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* doc/syntax/literals.rdoc (Strings): mention about ?a literal.
|
||||
|
||||
Sun Mar 26 02:35:17 2017 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ruby.c (process_options): convert -e script to the encoding
|
||||
|
|
|
@ -83,8 +83,33 @@ Any internal <tt>"</tt> must be 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,
|
||||
<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:
|
||||
|
||||
\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
|
||||
\M-\cx same as above
|
||||
\c\M-x same as above
|
||||
\c? or \C-? delete, ASCII 7Fh (DEL)
|
||||
|
||||
Any other character following a backslash is interpreted as the
|
||||
character itself.
|
||||
|
||||
Double-quote strings allow interpolation of other values using
|
||||
<tt>#{...}</tt>:
|
||||
|
@ -124,6 +149,23 @@ be concatenated as long as a percent-string is not last.
|
|||
%q{a} 'b' "c" #=> "abc"
|
||||
"a" 'b' %q{c} #=> NameError: uninitialized constant q
|
||||
|
||||
One more way of writing strings is using <tt>?</tt>:
|
||||
|
||||
?a #=> "a"
|
||||
|
||||
Basically only one character can be placed after <tt>?</tt>:
|
||||
|
||||
?abc #=> SyntaxError
|
||||
|
||||
Exceptionally, <tt>\C-</tt>, <tt>\M-</tt> and their combination are allowed
|
||||
before a character. They mean "control", "meta" and "control-meta"
|
||||
respectively:
|
||||
|
||||
?\C-a #=> "\x01"
|
||||
?\M-a #=> "\xE1"
|
||||
?\M-\C-a #=> "\x81"
|
||||
?\C-\M-a #=> "\x81", same as above
|
||||
|
||||
=== Here Documents
|
||||
|
||||
If you are writing a large block of text you may use a "here document" or
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.2.7"
|
||||
#define RUBY_RELEASE_DATE "2017-03-26"
|
||||
#define RUBY_PATCHLEVEL 446
|
||||
#define RUBY_PATCHLEVEL 447
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2017
|
||||
#define RUBY_RELEASE_MONTH 3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue