@@ -1162,12 +1162,44 @@ strio_readbyte(VALUE self)
11621162
11631163/*
11641164 * call-seq:
1165- * each_char {|c | ... } -> self
1165+ * each_char {|char | ... } -> self
11661166 *
11671167 * With a block given, calls the block with each remaining character in the stream;
1168- * see {Character IO}[rdoc-ref:IO@Character+IO].
1169- *
1170- * With no block given, returns an enumerator.
1168+ * positions the stream at end-of-file;
1169+ * returns +self+:
1170+ *
1171+ * chars = []
1172+ * strio = StringIO.new('hello')
1173+ * strio.each_char {|char| chars.push(char) }
1174+ * strio.eof? # => true
1175+ * chars # => ["h", "e", "l", "l", "o"]
1176+ * chars = []
1177+ * strio = StringIO.new('тест')
1178+ * strio.each_char {|char| chars.push(char) }
1179+ * chars # => ["т", "е", "с", "т"]
1180+ * chars = []
1181+ * strio = StringIO.new('こんにちは')
1182+ * strio.each_char {|char| chars.push(char) }
1183+ * chars # => ["こ", "ん", "に", "ち", "は"]
1184+ *
1185+ * Stream position matters:
1186+ *
1187+ * chars = []
1188+ * strio = StringIO.new('こんにちは')
1189+ * strio.getc # => "こ"
1190+ * strio.pos # => 3 # 3-byte character was read.
1191+ * strio.each_char {|char| chars.push(char) }
1192+ * chars # => ["ん", "に", "ち", "は"]
1193+ *
1194+ * When at end-of-stream does not call the block:
1195+ *
1196+ * strio.eof? # => true
1197+ * strio.each_char {|char| fail 'Boo!' }
1198+ * strio.eof? # => true
1199+ *
1200+ * With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].
1201+ *
1202+ * Related: StringIO.each_byte, StringIO.each_codepoint, StringIO.each_line.
11711203 */
11721204static VALUE
11731205strio_each_char (VALUE self )
0 commit comments