From: cremno@... Date: 2015-06-29T23:12:26+00:00 Subject: [ruby-core:69780] [Ruby trunk - Bug #11320] [Open] reopening stdio streams with non-ANSI filenames fails on Windows Issue #11320 has been reported by cremno phobia. ---------------------------------------- Bug #11320: reopening stdio streams with non-ANSI filenames fails on Windows https://bugs.ruby-lang.org/issues/11320 * Author: cremno phobia * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- ~~~ruby fname = '���������' File.write(fname, '') p File.exist?(fname) $stdin.reopen(fname, 'r') ~~~ It fails with `Errno::ENOENT` on Windows even though the file exists and is readable. It's caused by using `freopen()` (https://github.com/ruby/ruby/blob/v2_2_2/io.c#L6765). A wrapper that converts to UTF-16LE and then calls `wfreopen()` has to be added to `win32/win32.c`. -- https://bugs.ruby-lang.org/