From c2bd933980a486615e676802fa36ecf97c8e6682 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Sat, 27 Dec 2025 17:39:46 +0000 Subject: [PATCH] [DOC] Japanese for multi-byte characters --- doc/stringio/each_byte.rdoc | 5 +---- doc/stringio/each_char.rdoc | 5 +---- doc/stringio/each_codepoint.rdoc | 5 +---- doc/stringio/getbyte.rdoc | 6 ------ doc/stringio/getc.rdoc | 4 ---- doc/stringio/gets.rdoc | 16 ++++++++-------- doc/stringio/size.rdoc | 1 - doc/stringio/stringio.md | 16 +++++++++------- 8 files changed, 20 insertions(+), 38 deletions(-) diff --git a/doc/stringio/each_byte.rdoc b/doc/stringio/each_byte.rdoc index a635ce33..5201afb0 100644 --- a/doc/stringio/each_byte.rdoc +++ b/doc/stringio/each_byte.rdoc @@ -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) } diff --git a/doc/stringio/each_char.rdoc b/doc/stringio/each_char.rdoc index d0ab189d..bde0e3a3 100644 --- a/doc/stringio/each_char.rdoc +++ b/doc/stringio/each_char.rdoc @@ -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) } diff --git a/doc/stringio/each_codepoint.rdoc b/doc/stringio/each_codepoint.rdoc index 2fc33f46..af70b4c4 100644 --- a/doc/stringio/each_codepoint.rdoc +++ b/doc/stringio/each_codepoint.rdoc @@ -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) } diff --git a/doc/stringio/getbyte.rdoc b/doc/stringio/getbyte.rdoc index 48c334b5..61d2fc00 100644 --- a/doc/stringio/getbyte.rdoc +++ b/doc/stringio/getbyte.rdoc @@ -14,12 +14,6 @@ Returns +nil+ if at end-of-stream: Returns a byte, not a character: - s = 'тест' - s.bytes # => [209, 130, 208, 181, 209, 129, 209, 130] - strio = StringIO.new(s) - strio.getbyte # => 209 - strio.getbyte # => 130 - s = 'こんにちは' s.bytes # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175] strio = StringIO.new(s) diff --git a/doc/stringio/getc.rdoc b/doc/stringio/getc.rdoc index c021789c..bfb837bf 100644 --- a/doc/stringio/getc.rdoc +++ b/doc/stringio/getc.rdoc @@ -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 # => "ん" diff --git a/doc/stringio/gets.rdoc b/doc/stringio/gets.rdoc index 892c3feb..1186d6fe 100644 --- a/doc/stringio/gets.rdoc +++ b/doc/stringio/gets.rdoc @@ -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('тест') # Four 2-byte characters. + strio = StringIO.new('こんにちは') # Five 3-byte characters. strio.pos # => 0 - strio.gets # => "тест" - strio.pos # => 8 + strio.gets # => "こんにちは" + strio.pos # => 15 Argument +sep+ @@ -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('тест') # Four 2-byte characters. - strio.pos = 2 # At beginning of second character. - strio.gets # => "ест" - strio.pos = 3 # In middle of second character. - strio.gets # => "\xB5ст" + 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にちは" Special Record Separators diff --git a/doc/stringio/size.rdoc b/doc/stringio/size.rdoc index 9323adf8..253c612c 100644 --- a/doc/stringio/size.rdoc +++ b/doc/stringio/size.rdoc @@ -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. diff --git a/doc/stringio/stringio.md b/doc/stringio/stringio.md index 8931d1c3..07071ee9 100644 --- a/doc/stringio/stringio.md +++ b/doc/stringio/stringio.md @@ -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