Skip to content
instance method

String#codepoints

() -> ::Array[::Integer]
() { (::Integer codepoint) -> void } -> self
codepoints → array_of_integers

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.

See also #clear #concat #chr #count also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0