instance method
String#length
() -> ::Integer
length → integer
string.c
View on GitHub ↗
VALUE
rb_str_length(VALUE str)
{
return LONG2NUM(str_strlen(str, NULL));
}
Returns the count of characters (not bytes) in self:
Example
'foo'.length # => 3 'тест'.length # => 4 'こんにちは'.length # => 5
Contrast with String#bytesize:
Example
'foo'.bytesize # => 3 'тест'.bytesize # => 8 'こんにちは'.bytesize # => 15
Related: see Querying.