From 6079156400349fde810e7a5e7a52b81344e04b85 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 17 Aug 2008 04:25:56 +0000 Subject: * include/ruby/encoding.h (rb_econv_putbackable): declared. (rb_econv_putback): ditto. * transcode.c (rb_econv_putbackable): implemented. (rb_econv_putback): ditto. * io.c (io_getc): put back bytes if possible. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io_m17n.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 6d7b4f7f9..6cec7a05b 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -216,6 +216,16 @@ EOT } end + def test_getc_invalid + with_pipe("euc-jp:utf-8") {|r, w| + w << "\xa1xyz" + w.close + err = assert_raise(Encoding::InvalidByteSequence) { r.getc } + assert_equal("\xA1".force_encoding("ascii-8bit"), err.error_bytes) + assert_equal("xyz", r.read(10)) + } + end + def test_getc_stateful_conversion with_tmpdir { src = "\e$B\x23\x30\x23\x31\e(B".force_encoding("iso-2022-jp") -- cgit