File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1- Reads and returns the next character from the stream:
1+ Reads and returns the next character (or byte; see below) from the stream:
22
33 strio = StringIO.new('foo')
44 strio.getc # => "f"
@@ -20,4 +20,15 @@ Returns characters, not bytes:
2020 strio.getc # => "こ"
2121 strio.getc # => "ん"
2222
23+ In each of the examples above, the stream is positioned at the beginning of a character;
24+ in other cases that need not be true:
25+
26+ strio = StringIO.new('こんにちは') # Five 3-byte characters.
27+ strio.pos = 3 # => 3 # At beginning of second character; returns character.
28+ strio.getc # => "ん"
29+ strio.pos = 4 # => 4 # At second byte of second character; returns byte.
30+ strio.getc # => "\x82"
31+ strio.pos = 5 # => 5 # At third byte of second character; returns byte.
32+ strio.getc # => "\x93"
33+
2334Related: StringIO.getbyte.
Original file line number Diff line number Diff line change @@ -956,7 +956,7 @@ strio_each_byte(VALUE self)
956956
957957/*
958958 * call-seq:
959- * getc -> character or nil
959+ * getc -> character, byte, or nil
960960 *
961961 * :include: stringio/getc.rdoc
962962 *
You can’t perform that action at this time.
0 commit comments