Count characters of a string in Ruby
Code points
The length
or size
methods are available for String
objects.
count = str.length
count = str.size
Grapheme clusters
The core language does not provide a way to count grapheme clusters. If you know of a library with this functionality, please contribute it here.