summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2022-12-21 12:34:08 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2022-12-22 13:10:22 -0500
commitbba2bfc97512014134ea1c172e7a077bddebdbad (patch)
tree7a2825edc2aeedd55bc2c38e96a080fa089dda2a /doc
parent95a1d1fde8fb13d6b7bd6d63864d3bae8b34b0b0 (diff)
[DOC] encodings.rdoc: universal_newline reacts to \r
It wasn't clear that the mode also translates "\r" to "\n".
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6981
Diffstat (limited to 'doc')
-rw-r--r--doc/encodings.rdoc11
1 files changed, 6 insertions, 5 deletions
diff --git a/doc/encodings.rdoc b/doc/encodings.rdoc
index c61ab11e9a..1f3c54d740 100644
--- a/doc/encodings.rdoc
+++ b/doc/encodings.rdoc
@@ -467,12 +467,13 @@ These keyword-value pairs specify encoding options:
with a carriage-return character (<tt>"\r"</tt>).
- <tt>:crlf_newline: true</tt>: Replace each line-feed character (<tt>"\n"</tt>)
with a carriage-return/line-feed string (<tt>"\r\n"</tt>).
- - <tt>:universal_newline: true</tt>: Replace each carriage-return/line-feed string
+ - <tt>:universal_newline: true</tt>: Replace each carriage-return
+ character (<tt>"\r"</tt>) and each carriage-return/line-feed string
(<tt>"\r\n"</tt>) with a line-feed character (<tt>"\n"</tt>).
Examples:
- s = "\n \r\n" # => "\n \r\n"
- s.encode('ASCII', cr_newline: true) # => "\r \r\r"
- s.encode('ASCII', crlf_newline: true) # => "\r\n \r\r\n"
- s.encode('ASCII', universal_newline: true) # => "\n \n"
+ s = "\n \r \r\n" # => "\n \r \r\n"
+ s.encode('ASCII', cr_newline: true) # => "\r \r \r\r"
+ s.encode('ASCII', crlf_newline: true) # => "\r\n \r \r\r\n"
+ s.encode('ASCII', universal_newline: true) # => "\n \n \n"