Skip to content

Commit 26d8f60

Browse files
[DOC] Japanese for multi-byte characters (#201)
1 parent d6dd409 commit 26d8f60

File tree

8 files changed

+20
-39
lines changed

8 files changed

+20
-39
lines changed

doc/stringio/each_byte.rdoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ returns +self+:
77
strio.each_byte {|byte| bytes.push(byte) }
88
strio.eof? # => true
99
bytes # => [104, 101, 108, 108, 111]
10-
bytes = []
11-
strio = StringIO.new('тест') # Four 2-byte characters.
12-
strio.each_byte {|byte| bytes.push(byte) }
13-
bytes # => [209, 130, 208, 181, 209, 129, 209, 130]
10+
1411
bytes = []
1512
strio = StringIO.new('こんにちは') # Five 3-byte characters.
1613
strio.each_byte {|byte| bytes.push(byte) }

doc/stringio/each_char.rdoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ returns +self+:
77
strio.each_char {|char| chars.push(char) }
88
strio.eof? # => true
99
chars # => ["h", "e", "l", "l", "o"]
10-
chars = []
11-
strio = StringIO.new('тест')
12-
strio.each_char {|char| chars.push(char) }
13-
chars # => ["т", "е", "с", "т"]
10+
1411
chars = []
1512
strio = StringIO.new('こんにちは')
1613
strio.each_char {|char| chars.push(char) }

doc/stringio/each_codepoint.rdoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ Each codepoint is the integer value for a character; returns self:
99
strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
1010
strio.eof? # => true
1111
codepoints # => [104, 101, 108, 108, 111]
12-
codepoints = []
13-
strio = StringIO.new('тест')
14-
strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
15-
codepoints # => [1090, 1077, 1089, 1090]
12+
1613
codepoints = []
1714
strio = StringIO.new('こんにちは')
1815
strio.each_codepoint {|codepoint| codepoints.push(codepoint) }

doc/stringio/getbyte.rdoc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ Returns +nil+ if at end-of-stream:
1414

1515
Returns a byte, not a character:
1616

17-
s = 'Привет'
18-
s.bytes
19-
# => [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
20-
strio = StringIO.new(s)
21-
strio.getbyte # => 208
22-
strio.getbyte # => 159
23-
2417
s = 'こんにちは'
2518
s.bytes
2619
# => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]

doc/stringio/getc.rdoc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ Returns +nil+ if at end-of-stream:
1212

1313
Returns characters, not bytes:
1414

15-
strio = StringIO.new('Привет')
16-
strio.getc # => "П"
17-
strio.getc # => "р"
18-
1915
strio = StringIO.new('こんにちは')
2016
strio.getc # => "こ"
2117
strio.getc # => "ん"

doc/stringio/gets.rdoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ With no arguments given, reads a line using the default record separator
1919
strio.eof? # => true
2020
strio.gets # => nil
2121

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

2727
<b>Argument +sep+</b>
2828

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

6868
The position need not be at a character boundary:
6969

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

7676
<b>Special Record Separators</b>
7777

doc/stringio/size.rdoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Returns the number of bytes in the string in +self+:
22

33
StringIO.new('hello').size # => 5 # Five 1-byte characters.
4-
StringIO.new('тест').size # => 8 # Four 2-byte characters.
54
StringIO.new('こんにちは').size # => 15 # Five 3-byte characters.

doc/stringio/stringio.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,15 @@ strio.pos = 24
409409
strio.gets # => "Fourth line\n"
410410
strio.pos # => 36
411411

412-
strio = StringIO.new('тест') # Four 2-byte characters.
413-
strio.pos = 0 # At first byte of first character.
414-
strio.read # => "тест"
415-
strio.pos = 1 # At second byte of first character.
416-
strio.read # => "\x82ест"
417-
strio.pos = 2 # At first of second character.
418-
strio.read # => "ест"
412+
strio = StringIO.new('こんにちは') # Five 3-byte characters.
413+
strio.pos = 0 # At first byte of first character.
414+
strio.read # => "こんにちは"
415+
strio.pos = 1 # At second byte of first character.
416+
strio.read # => "\x81\x93んにちは"
417+
strio.pos = 2 # At third byte of first character.
418+
strio.read # => "\x93んにちは"
419+
strio.pos = 3 # At first byte of second character.
420+
strio.read # => "んにちは"
419421

420422
strio = StringIO.new(TEXT)
421423
strio.pos = 15

0 commit comments

Comments
 (0)