Issue #7379 has been updated by luislavena (Luis Lavena).

Category set to core
Status changed from Open to Assigned
Assignee set to usa (Usaku NAKAMURA)
Target version set to 2.0.0

Hello Park,

I don't have Windows 8 right now to test, but is great to hear this got fixed (finally).

I'm assigning to Nakamura-san for approval.

Thank you.


----------------------------------------
Bug #7379: Unexpected result of Kernel#gets on Windows 8
https://bugs.ruby-lang.org/issues/7379#change-33020

Author: phasis68 (Heesob Park)
Status: Assigned
Priority: Normal
Assignee: usa (Usaku NAKAMURA)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-17 trunk 37691) [i386-mswin32_110]


I found Kernel#gets returns invalid result for multi-byte string on Windows 8.

C:\Users\phasis>ruby -ve 'p gets'
ruby 2.0.0dev (2012-11-17 trunk 37691) [i386-mswin32_110]
???κΈ?
"\xC7\x00\xB1\x00\n"

After some debugging,I noticed that the previous ReadFile bug on console was fixed on Windows 8.
So the workaround code should be skipped on Windows 8.

Here is a patch:
cf. The OS version number of Windows 8 and Windows Server 2012 is 6.2.

diff --git a/win32.c b/win32.c.new
index 3446728..5635058 100644
--- a/win32.c
+++ b/win32.c.new
@@ -5902,7 +5902,7 @@ rb_w32_read(int fd, void *buf, size_t size)
     }
 
     ret = 0;
-    isconsole = is_console(_osfhnd(fd));
+    isconsole = is_console(_osfhnd(fd)) && !(osver.dwMajorVersion==6 && osver.dwMinorVersion==2);
     if (isconsole) {
 	DWORD mode;
 	GetConsoleMode((HANDLE)_osfhnd(fd),&mode);



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