From: Masaya TARUI Date: 2010-11-30T06:06:27+09:00 Subject: [ruby-core:33471] Re: [Ruby 1.9-Bug#4097][Open] Unexpected result of STDIN.read on Windows Hello, WindowsXP seems have a bug at read functions under multibyte console inputs. I found a issue of coming from same bug of Windows. :-( does anybody have a good workaround idea ? > ruby -ve 'a=STDIN.read(6);p [a,a.length];a=STDIN.read(2);p [a,a.length];' ruby 1.9.3dev (2010-11-30 trunk 29978) [i386-mswin32_100] ���������������aiueo ["\x82\xA0\x82\xA2\x82\xA4", 6] ["iu", 2] >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 Regards, Masaya TARUI