From 965e9df38045594d126991e6a109c5746242d2ba Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 8 Nov 2015 01:55:14 +0000 Subject: io.c: [DOC] IO#gets [skip ci] * io.c (rb_io_gets_m): Update IO#gets doc for characters more than 1 byte. [Fix GH-1085] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ io.c | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index dd5cad2be5..f280506836 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Nov 8 10:55:10 2015 Anton Davydov + + * io.c (rb_io_gets_m): Update IO#gets doc for characters more than + 1 byte. [Fix GH-1085] + Sun Nov 8 10:37:58 2015 SHIBATA Hiroshi * lib/uri/ftp.rb: fix a typo. diff --git a/io.c b/io.c index 7932a68942..0305386507 100644 --- a/io.c +++ b/io.c @@ -3291,6 +3291,16 @@ rb_io_gets(VALUE io) * * File.new("testfile").gets #=> "This is line one\n" * $_ #=> "This is line one\n" + * + * If StringIO contains characters more than 1 byte + * then gets(1) returns character entirely: + * + * # russian characters take 2 bytes + * File.write("testfile", "\u{442 435 441 442}") + * File.open("testfile") {|f|f.gets(1)} #=> "\u0442" + * File.open("testfile") {|f|f.gets(2)} #=> "\u0442" + * File.open("testfile") {|f|f.gets(3)} #=> "\u0442\u0435" + * File.open("testfile") {|f|f.gets(4)} #=> "\u0442\u0435" */ static VALUE -- cgit v1.2.3