1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/doc/string/b.rdoc
Burdette Lamar 056b7a8633
[DOC] Enhanced RDoc for String (#5742)
Treats:
    #force_encoding
    #b
    #valid_encoding?
    #ascii_only?
    #scrub
    #scrub!
    #unicode_normalized?
Plus a couple of minor tweaks.
2022-03-31 15:09:25 -05:00

14 lines
431 B
Text

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]