Hi, 2011/12/13 Luis Lavena <luislavena / gmail.com>: > On Sun, Dec 11, 2011 at 11:42 PM, U.Nakamura <usa / garbagecollect.jp> wrote: >> Hello, >> >> In message "[ruby-core:41578] [ruby-trunk - Bug #5714] Unexpected error of STDIN#read with non-ascii input on Windows XP" >> on Dec.10,2011 06:49:55, <luislavena / gmail.com> wrote: >>> Category set to build >> >> build? >> > > Sorry, meant to set core, but we don't have any category to describe > platform-specific issues. > >> >>> Usa, what do you think about attached read_binmode.patch? >> >> Difficult, difficult... >> >> Of course, as Shirosaki-san says, IO#read with length should always >> be binary mode. >> But if setting binmode once, it's never canceled. >> So, I doubt that such implicit mode setting in IO#read is right. >> > > Agree. > > Hiroshi and Heesob, do you guys think can solve this without reverting > the changes of #5562? > > If not, then reverting seems the only alternative. I think setting binary mode only for stdin is a possible choice like this: diff --git a/win32.c b/win32.c.new index 67a392e..db9e222 100644 --- a/win32.c +++ b/win32.c.new @@ -2259,3 +2259,6 @@ init_stdhandle(void) if (fileno(stdin) < 0) { stdin->_file = open_null(0); } + else { + setmode(fileno(stdin), O_BINARY); + } Regards, Park Heesob