ruby/doc/string/bytesize.rdoc
2025-06-24 02:28:05 +09:00

15 lines
354 B
Text

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