summaryrefslogtreecommitdiff
path: root/doc/string/b.rdoc
diff options
context:
space:
mode:
authorBurdette Lamar <[email protected]>2022-03-31 15:09:25 -0500
committerGitHub <[email protected]>2022-03-31 15:09:25 -0500
commit056b7a86335f38618c1749674a11e838de7c3c12 (patch)
treeb6c0eaabec11b7377c081b274e32ebeff04d2c86 /doc/string/b.rdoc
parentbb037f6d8639b7d36ef263ca24d4117d725e71ef (diff)
[DOC] Enhanced RDoc for String (#5742)
Treats: #force_encoding #b #valid_encoding? #ascii_only? #scrub #scrub! #unicode_normalized? Plus a couple of minor tweaks.
Notes
Notes: Merged-By: BurdetteLamar <[email protected]>
Diffstat (limited to 'doc/string/b.rdoc')
-rw-r--r--doc/string/b.rdoc14
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/string/b.rdoc b/doc/string/b.rdoc
new file mode 100644
index 0000000000..f8ad2910b4
--- /dev/null
+++ b/doc/string/b.rdoc
@@ -0,0 +1,14 @@
+Returns a copy of +self+ that has ASCII-8BIT encoding;
+the underlying bytes are not modified:
+
+ s = "\x99"
+ s.encoding # => #<Encoding:UTF-8>
+ t = s.b # => "\x99"
+ t.encoding # => #<Encoding:ASCII-8BIT>
+
+ s = "\u4095" # => "䂕"
+ s.encoding # => #<Encoding:UTF-8>
+ s.bytes # => [228, 130, 149]
+ t = s.b # => "\xE4\x82\x95"
+ t.encoding # => #<Encoding:ASCII-8BIT>
+ t.bytes # => [228, 130, 149]