instance method
String#codepoints
() -> ::Array[::Integer]
() { (::Integer codepoint) -> void } -> self
codepoints → array_of_integers
string.c
View on GitHub ↗
static VALUE
rb_str_codepoints(VALUE str)
{
VALUE ary = WANTARRAY("codepoints", rb_str_strlen(str));
return rb_str_enumerate_codepoints(str, ary);
}
Returns an array of the codepoints in self; each codepoint is the integer value for a character:
Example
'hello'.codepoints # => [104, 101, 108, 108, 111] 'тест'.codepoints # => [1090, 1077, 1089, 1090] 'こんにちは'.codepoints # => [12371, 12435, 12395, 12385, 12399] ''.codepoints # => []
Related: see Converting to Non-String.