Bug #4097: Unexpected result of STDIN.read on Windows
http://redmine.ruby-lang.org/issues/show/4097

Author: Heesob Park
Status: Open, Priority: Normal
Category: core, Target version: 1.9.x
ruby -v: ruby 1.9.3dev (2010-11-28 trunk 29965) [i386-mswin32_90]

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


----------------------------------------
http://redmine.ruby-lang.org