Project

General

Profile

Actions

Bug #1685

closed

Some windows unicode path issues remain

Added by spatulasnout (B Kelly) almost 15 years ago. Updated almost 10 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2009-06-24) [i386-mswin32_71]
Backport:
[ruby-core:24010]

Description

=begin
Hi,

I see some nice progress has been made in unicode path
handling on windows.

The following tests are not exhaustive, but do reveal some
remaining issues.

Everything below "NOT WORKING" fails in one way or another.

Regards,

Bill

# encoding: UTF-8

# Test unicode path/dir handling on windows

require 'test/unit'

class TestUnicodeFilenamesAndPaths < Test::Unit::TestCase
  def setup
    tmpdir = ENV['TEMP'] || "C:/TEMP"
    Dir.chdir tmpdir
    puts Dir.pwd
    testdir = "ruby_unicode_test"
    Dir.mkdir testdir unless test ?d, testdir
    Dir.chdir testdir
    puts Dir.pwd
  end
  
  def test_unicode_paths
    fname_resume = "R\xC3\xA9sum\xC3\xA9".force_encoding("UTF-8")
    fname_chinese = "\u52ec\u52ee\u52f1\u52f2.txt"
    dname_chinese = "\u52ec\u52ee\u52f1\u52f2"

    assert_equal( "UTF-8", fname_resume.encoding.name )
    File.open(fname_resume, "w") {|io| io.puts "Hello, World"}
    
    assert_equal( "UTF-8", fname_chinese.encoding.name )
    File.open(fname_chinese, "w") {|io| io.puts "Hello, World"}
    
    dat = File.read(fname_chinese)
    assert_equal( "Hello, World\n", dat )
    
    files = Dir["*"]
    assert( files.include? fname_resume )
    assert( files.include? fname_chinese )

# NOT WORKING:
    Dir.rmdir dname_chinese rescue nil
    Dir.mkdir dname_chinese
    test ?d, dname_chinese
    Dir.chdir dname_chinese
    cwd = Dir.pwd
    assert( cwd[(-dname_chinese.length)..-1] == dname_chinese )
    Dir.chdir ".."

    x = File.stat(fname_resume)
    x = File.stat(fname_chinese)
    x = File.stat(dname_chinese)
    
    assert( File.exist? fname_resume )
    assert( File.exist? fname_chinese )
    assert( test(?f, fname_resume) )
    assert( test(?f, fname_chinese) )

    files = Dir[fname_resume]
    assert_equal( fname_resume, files.first )
    files = Dir[fname_chinese]
    assert_equal( fname_chinese, files.first )
    files = Dir[dname_chinese]
    assert_equal( dname_chinese, files.first )
  end  
end
=end

Files

spatulasnout-unicode-mkdir-diffs.txt (3.56 KB) spatulasnout-unicode-mkdir-diffs.txt Diffs for win32 unicode support for Dir.mkdir spatulasnout (B Kelly), 03/25/2010 10:13 AM
test_io_unicode_paths.rb (925 Bytes) test_io_unicode_paths.rb new file: bootstraptest/test_io_unicode_paths.rb spatulasnout (B Kelly), 03/25/2010 10:13 AM

Related issues 4 (0 open4 closed)

Related to Ruby master - Feature #2255: unicode parameters cannot be passed to rubyClosedwindowsActions
Related to Ruby master - Bug #2332: Ruby doesn't run properly from unicode folder on windowsClosed11/04/2009Actions
Related to Ruby master - Bug #1771: system()/popen()/popen3() & windows & unicode is not workingClosedusa (Usaku NAKAMURA)07/13/2009Actions
Has duplicate Ruby master - Bug #2137: Dir.glob does not support unicode on WindowsClosedusa (Usaku NAKAMURA)09/23/2009Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0