mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Tweaks for String#bytesize
This commit is contained in:
parent
b1ce569ffc
commit
db6f397987
1 changed files with 12 additions and 8 deletions
|
@ -1,11 +1,15 @@
|
||||||
Returns the count of bytes (not characters) in +self+:
|
Returns the count of bytes in +self+.
|
||||||
|
|
||||||
'foo'.bytesize # => 3
|
Note that the byte count may be different from the character count (returned by #size):
|
||||||
'тест'.bytesize # => 8
|
|
||||||
'こんにちは'.bytesize # => 15
|
|
||||||
|
|
||||||
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
|
Related: see {Querying}[rdoc-ref:String@Querying].
|
||||||
'тест'.length # => 4
|
|
||||||
'こんにちは'.length # => 5
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue