Permalink
Browse files

Merge remote-tracking branch 'razielgn/dir-entries-encoding'

  • Loading branch information...
brixen committed Feb 24, 2014
2 parents fcc5b8c + 21f04d4 commit a66dbdfe589b436d00656bb3cea288276a51cc72
Showing with 15 additions and 1 deletion.
  1. +7 −0 spec/ruby/core/dir/entries_spec.rb
  2. +4 −0 spec/ruby/core/dir/fixtures/common.rb
  3. +4 −1 vm/builtin/dir.cpp
@@ -1,3 +1,5 @@
+# encoding: utf-8
+
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/common', __FILE__)
@@ -30,6 +32,11 @@
a = Dir.entries("#{DirSpecs.mock_dir}/deeply/nested", :encoding => "utf-8").sort
a.should == %w|. .. .dotfile.ext directory|
end
+
+ it "returns non-ascii entries properly encoded" do
+ entries = Dir.entries File.join(DirSpecs.mock_dir, 'special')
+ entries.should include("こんにちは.txt")
+ end
end
it "raises a SystemCallError if called with a nonexistent diretory" do
@@ -1,3 +1,5 @@
+# encoding: utf-8
+
module DirSpecs
def self.mock_dir(dirs = ['dir_specs_mock'])
@mock_dir ||= tmp("")
@@ -82,6 +84,8 @@ def self.mock_dir_files
special/}
special/test{1}/file[1]
+
+ special/こんにちは.txt
]
platform_is_not :windows do
View
@@ -86,7 +86,10 @@ namespace rubinius {
}
if(!entp) return cNil;
- return String::create(state, ent.d_name);
+
+ String* str = String::create(state, ent.d_name);
+ str->encoding(state, Encoding::default_external(state));
+ return str;
}
Object* Dir::control(STATE, Fixnum* kind, Integer* pos) {

0 comments on commit a66dbdf

Please sign in to comment.