From 1df96bd61b56734d7fc7089a44151d07b8da10e2 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Mon, 27 Oct 2025 20:43:15 +0100 Subject: [PATCH 1/3] [DOC] Doc for StringIO#each_codepoint --- ext/stringio/stringio.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 5c6568a..ba8bbaf 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1186,10 +1186,42 @@ strio_each_char(VALUE self) * call-seq: * each_codepoint {|codepoint| ... } -> self * - * With a block given, calls the block with each remaining codepoint in the stream; - * see {Codepoint IO}[rdoc-ref:IO@Codepoint+IO]. - * - * With no block given, returns an enumerator. + * With a block given, calls the block with each successive codepoint from self; + * sets the position to end-of-stream; + * returns +self+. + * + * Each codepoint is the integer value for a character; returns self: + * + * codepoints = [] + * strio = StringIO.new('hello') + * strio.each_codepoint {|codepoint| codepoints.push(codepoint) } + * strio.eof? # => true + * codepoints # => [104, 101, 108, 108, 111] + * codepoints = [] + * strio = StringIO.new('тест') + * strio.each_codepoint {|codepoint| codepoints.push(codepoint) } + * codepoints # => [1090, 1077, 1089, 1090] + * codepoints = [] + * strio = StringIO.new('こんにちは') + * strio.each_codepoint {|codepoint| codepoints.push(codepoint) } + * codepoints # => [12371, 12435, 12395, 12385, 12399] + * + * Position in the stream matters: + * + * codepoints = [] + * strio = StringIO.new('こんにちは') + * strio.getc # => "こ" + * strio.pos # => 3 + * strio.each_codepoint {|codepoint| codepoints.push(codepoint) } + * codepoints # => [12435, 12395, 12385, 12399] + * + * When at end-of-stream, the block is not called: + * + * strio.eof? # => true + * strio.each_codepoint {|codepoint| fail 'Boo!' } + * strio.eof? # => true + * + * With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html]. */ static VALUE strio_each_codepoint(VALUE self) From d633d855cd859072b6c527e1d6a8a7743230969e Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Mon, 27 Oct 2025 20:46:02 +0100 Subject: [PATCH 2/3] [DOC] Doc for StringIO#each_codepoint --- ext/stringio/stringio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index ba8bbaf..a4548fb 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1222,6 +1222,8 @@ strio_each_char(VALUE self) * strio.eof? # => true * * With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html]. + * + * Related: StringIO#each_byte, StringIO.each_char, StringIO.each_line. */ static VALUE strio_each_codepoint(VALUE self) From 4ba9c6f45478478544f805887fd65563ca4de8ed Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 28 Oct 2025 12:08:47 +0900 Subject: [PATCH 3/3] Fix separator --- ext/stringio/stringio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index a4548fb..e8cbafe 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1223,7 +1223,7 @@ strio_each_char(VALUE self) * * With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html]. * - * Related: StringIO#each_byte, StringIO.each_char, StringIO.each_line. + * Related: StringIO#each_byte, StringIO#each_char, StringIO#each_line. */ static VALUE strio_each_codepoint(VALUE self)