Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

IO#each_codepoint

() { (::Integer c) -> void } -> self
() -> ::Enumerator[::Integer, self]
each_codepoint {|c| ... } → self
each_codepoint → enumerator

Calls the given block with each codepoint in the stream; returns self:

Example
f = File.new('t.rus')
a = []
f.each_codepoint {|c| a << c }
a # => [1090, 1077, 1089, 1090]
f.close

Returns an Enumerator if no block is given.

Related: IO#each_byte, IO#each_char.

See also #each_char #each_line #each_byte #echo= also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0