I am creating a temporary directory in Ruby using ‘tmpdir’, and adding a file in the temporary directory that has a non-English file name:
#!/usr/bin/env ruby -KU
# coding:utf-8
require 'tmpdir'
Dir.mktmpdir { |dir| File.open( "#{dir}/файл.txt", "w" ) {} }
The program fails on cleanup, attempting to delete “????.txt”. I can see the file is being created with the appropriate name.
I am running Ruby 1.9 on Windows. Is there some way to fix this, or is Ruby 1.9 not intended to be used with non-English characters on Windows?
This is a bug introduced more than 2 years ago by typo. Will be fixed in Ruby 2.0 🙁
http://goo.gl/SsAA8
For ruby version < 2.0 this hack defined after
require 'tmpdir'will fix a problem: