diff options
author | Earlopain <[email protected]> | 2024-12-13 08:43:14 +0100 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2025-01-07 07:56:48 +0900 |
commit | 89c505dc479a081aa4cc69add29855b182d52b7d (patch) | |
tree | 77e38bfbb4639dbdbc607b1006bbe87cdde07c0d /doc/syntax/literals.rdoc | |
parent | b0d291ec83dd8140f7319f94bff6566681678c59 (diff) |
Move string escape sequence documention further down
If someone looks at documention for strings,
I don't think escape sequences is what they look
for in majority of the cases.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12318
Diffstat (limited to 'doc/syntax/literals.rdoc')
-rw-r--r-- | doc/syntax/literals.rdoc | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/doc/syntax/literals.rdoc b/doc/syntax/literals.rdoc index ac2a1daa9b..026266dff7 100644 --- a/doc/syntax/literals.rdoc +++ b/doc/syntax/literals.rdoc @@ -138,46 +138,6 @@ Also \Rational numbers may be imaginary numbers. == \String Literals -=== Escape Sequences - -Some characters can be represented as escape sequences in -double-quoted strings, -character literals, -here document literals (non-quoted, double-quoted, and with backticks), -double-quoted symbols, -double-quoted symbol keys in Hash literals, -Regexp literals, and -several percent literals (<tt>%</tt>, <tt>%Q</tt>, <tt>%W</tt>, <tt>%I</tt>, <tt>%r</tt>, <tt>%x</tt>). - -They allow escape sequences 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) - \<newline> continuation line (empty string) - -The last one, <tt>\<newline></tt>, represents an empty string instead of a character. -It is used to fold a line in a string. - === Double-Quoted \String Literals The most common way of writing strings is using <tt>"</tt>: @@ -265,6 +225,46 @@ that corresponds to a single codepoint in the script encoding: ?\C-\M-a #=> "\x81", same as above ?あ #=> "あ" +=== Escape Sequences + +Some characters can be represented as escape sequences in +double-quoted strings, +character literals, +here document literals (non-quoted, double-quoted, and with backticks), +double-quoted symbols, +double-quoted symbol keys in Hash literals, +Regexp literals, and +several percent literals (<tt>%</tt>, <tt>%Q</tt>, <tt>%W</tt>, <tt>%I</tt>, <tt>%r</tt>, <tt>%x</tt>). + +They allow escape sequences 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) + \<newline> continuation line (empty string) + +The last one, <tt>\<newline></tt>, represents an empty string instead of a character. +It is used to fold a line in a string. + === Here Document Literals If you are writing a large block of text you may use a "here document" or |