[ruby-core:71366] [Ruby trunk - Bug #11412] The default filename encoding causes errors on Windows

From: naruse@...
Date: 2015-11-06 02:25:31 UTC
List: ruby-core #71366
Issue #11412 has been updated by Yui NARUSE.


Matthew Simoneau wrote:
> I'd like to see this issue reopened.
> 
> The solution of specifying UTF-8 explicitly works, but this should be the default for Ruby on Windows. Two reasons:
> 
> 1) This is a serious usability issue. It took me half an hour to work this out. Problems like this contribute to the perception (or reality) that Windows is a second-class platform.
> 
> 2) More significantly, higher-level functions like Pathname#children don't let you specify the encoding. You have to rework this code to call Dir.foreach of similar directly instead.

Of course the change is discussing but it is still pending because of compatibility.
It can be changed at Ruby 3.0.

----------------------------------------
Bug #11412: The default filename encoding causes errors on Windows
https://bugs.ruby-lang.org/issues/11412#change-54736

* Author: Daniel Frank
* Status: Rejected
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Ruby is apparently unable to find files it just told me are there (containing japanese characters).
Demo code:
Dir.foreach('.') do |entry|
	puts "#{entry} exists? " + File.exist?(entry).to_s
end

Output:
C:\tmp\test\filenames>C:\tmp\rubybackup\ruby-2.2.2-x64-mingw32\bin\ruby.exe test.rb
. exists? true
.. exists? true
a.md exists? true
b.txt exists? true
test.rb exists? true
???.txt exists? false

Directory contents according to cmd.exe/dir:
02.08.2015  22:18    <DIR>          .
02.08.2015  22:18    <DIR>          ..
02.08.2015  22:04                 0 a.md
02.08.2015  22:04                 0 b.txt
02.08.2015  22:20                87 test.rb
02.08.2015  22:04                 0 ???.txt

The undisplayable filename contains japanese characters and should read: 小悪党.txt

C:\tmp\test\filenames>chcp
Active code page: 850

Attached zip file contains all files necessary to see the problem (with the exception of the script the files have a size of zero bytes).

---Files--------------------------------
filenames.zip (611 Bytes)


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

In This Thread

Prev Next