Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions doc/stringio/each_byte.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ returns +self+:
strio.each_byte {|byte| bytes.push(byte) }
strio.eof? # => true
bytes # => [104, 101, 108, 108, 111]
bytes = []
strio = StringIO.new('тест') # Four 2-byte characters.
strio.each_byte {|byte| bytes.push(byte) }
bytes # => [209, 130, 208, 181, 209, 129, 209, 130]

bytes = []
strio = StringIO.new('こんにちは') # Five 3-byte characters.
strio.each_byte {|byte| bytes.push(byte) }
Expand Down
5 changes: 1 addition & 4 deletions doc/stringio/each_char.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ returns +self+:
strio.each_char {|char| chars.push(char) }
strio.eof? # => true
chars # => ["h", "e", "l", "l", "o"]
chars = []
strio = StringIO.new('тест')
strio.each_char {|char| chars.push(char) }
chars # => ["т", "е", "с", "т"]

chars = []
strio = StringIO.new('こんにちは')
strio.each_char {|char| chars.push(char) }
Expand Down
5 changes: 1 addition & 4 deletions doc/stringio/each_codepoint.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ Each codepoint is the integer value for a character; returns self:
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) }
Expand Down
7 changes: 0 additions & 7 deletions doc/stringio/getbyte.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ Returns +nil+ if at end-of-stream:

Returns a byte, not a character:

s = 'Привет'
s.bytes
# => [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
strio = StringIO.new(s)
strio.getbyte # => 208
strio.getbyte # => 159

s = 'こんにちは'
s.bytes
# => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
Expand Down
4 changes: 0 additions & 4 deletions doc/stringio/getc.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ Returns +nil+ if at end-of-stream:

Returns characters, not bytes:

strio = StringIO.new('Привет')
strio.getc # => "П"
strio.getc # => "р"

strio = StringIO.new('こんにちは')
strio.getc # => "こ"
strio.getc # => "ん"
Expand Down
16 changes: 8 additions & 8 deletions doc/stringio/gets.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ With no arguments given, reads a line using the default record separator
strio.eof? # => true
strio.gets # => nil

strio = StringIO.new('Привет') # Six 2-byte characters
strio = StringIO.new('こんにちは') # Five 3-byte characters.
strio.pos # => 0
strio.gets # => "Привет"
strio.pos # => 12
strio.gets # => "こんにちは"
strio.pos # => 15

<b>Argument +sep+</b>

Expand Down Expand Up @@ -67,11 +67,11 @@ but in other cases the position may be anywhere:

The position need not be at a character boundary:

strio = StringIO.new('Привет') # Six 2-byte characters.
strio.pos = 2 # At beginning of second character.
strio.gets # => "ривет"
strio.pos = 3 # In middle of second character.
strio.gets # => "\x80ивет"
strio = StringIO.new('こんにちは') # Five 3-byte characters.
strio.pos = 3 # At beginning of second character.
strio.gets # => "んにちは"
strio.pos = 4 # Within second character.
strio.gets # => "\x82\x93にちは"

<b>Special Record Separators</b>

Expand Down
1 change: 0 additions & 1 deletion doc/stringio/size.rdoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Returns the number of bytes in the string in +self+:

StringIO.new('hello').size # => 5 # Five 1-byte characters.
StringIO.new('тест').size # => 8 # Four 2-byte characters.
StringIO.new('こんにちは').size # => 15 # Five 3-byte characters.
16 changes: 9 additions & 7 deletions doc/stringio/stringio.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,15 @@ strio.pos = 24
strio.gets # => "Fourth line\n"
strio.pos # => 36

strio = StringIO.new('тест') # Four 2-byte characters.
strio.pos = 0 # At first byte of first character.
strio.read # => "тест"
strio.pos = 1 # At second byte of first character.
strio.read # => "\x82ест"
strio.pos = 2 # At first of second character.
strio.read # => "ест"
strio = StringIO.new('こんにちは') # Five 3-byte characters.
strio.pos = 0 # At first byte of first character.
strio.read # => "こんにちは"
strio.pos = 1 # At second byte of first character.
strio.read # => "\x81\x93んにちは"
strio.pos = 2 # At third byte of first character.
strio.read # => "\x93んにちは"
strio.pos = 3 # At first byte of second character.
strio.read # => "んにちは"

strio = StringIO.new(TEXT)
strio.pos = 15
Expand Down
Loading