Tweaks for String#bytesize

This commit is contained in:
BurdetteLamar 2025-06-21 11:58:50 -05:00 committed by Peter Zhu
parent b1ce569ffc
commit db6f397987

View file

@ -1,11 +1,15 @@
Returns the count of bytes (not characters) in +self+:
Returns the count of bytes in +self+.
'foo'.bytesize # => 3
'тест'.bytesize # => 8
'こんにちは'.bytesize # => 15
Note that the byte count may be different from the character count (returned by #size):
Contrast with String#length:
s = 'foo'
s.bytesize # => 3
s.size # => 3
s = 'тест'
s.bytesize # => 8
s.size # => 4
s = 'こんにちは'
s.bytesize # => 15
s.size # => 5
'foo'.length # => 3
'тест'.length # => 4
'こんにちは'.length # => 5
Related: see {Querying}[rdoc-ref:String@Querying].