From: Masaya Tarui Date: 2011-07-27T04:34:55+09:00 Subject: [ruby-core:38531] [Ruby 1.9 - Bug #4097][Third Party's Issue] Unexpected result of STDIN.read on Windows Issue #4097 has been updated by Masaya Tarui. Status changed from Assigned to Third Party's Issue Sorry for a delayed response. Now, STDIN.read(n) under multibyte console inputs might return n+1 bytes String.(by r29980 and r30280) Multibyte character is never split in read of MS runtime. And, it is difficult to do STDIN.ungetc last byte because of lapping C-level read function. I think that 1) it's windows bug, 2) we don't have an api base workaround , and 3) we can apply a workaround to application. So, I change status to 3rd party's issue. However, the patch is always a welcome. Thanks, Masaya TARUI ---------------------------------------- Bug #4097: Unexpected result of STDIN.read on Windows http://redmine.ruby-lang.org/issues/4097 Author: Heesob Park Status: Third Party's Issue Priority: Normal Assignee: Masaya Tarui Category: core Target version: 1.9.3 ruby -v: ruby 1.9.3dev (2010-11-28 trunk 29965) [i386-mswin32_90] =begin On Ruby 1.9.x, in case of non-ASCII input, STDIN.read(n) returns some garbage attached string. C:\work>ruby -ve 'a=STDIN.read(10);p a;p a.length' ruby 1.9.3dev (2010-11-28 trunk 29965) [i386-mswin32_90] ������������abcd "\xB0\xA1\xB3\xAA\xB4\xD9\xB6\xF3ab\x00\x00\xB8t" 14 On the other hand, Ruby 1.8.6 works fine. C:\work>ruby -ve 'a=STDIN.read(10);p a;p a.length' ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32] ������������abcd "\260\241\263\252\264\331\266\363ab" 10 =end -- http://redmine.ruby-lang.org