Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit a66dbdfe589b436d00656bb3cea288276a51cc72 2 parents fcc5b8c + 21f04d4
@brixen brixen authored
View
7 spec/ruby/core/dir/entries_spec.rb
@@ -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
View
4 spec/ruby/core/dir/fixtures/common.rb
@@ -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
5 vm/builtin/dir.cpp
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.