File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -1289,7 +1289,11 @@ def door?
12891289
12901290 def entries
12911291 opts = { }
1292- opts [ :encoding ] = fu_windows? ? ::Encoding ::UTF_8 : path . encoding
1292+ if fu_windows? && ::Encoding . compatible? ( ::Encoding ::UTF_8 , path . encoding )
1293+ opts [ :encoding ] = ::Encoding ::UTF_8
1294+ else
1295+ opts [ :encoding ] = path . encoding
1296+ end
12931297
12941298 files = if Dir . respond_to? ( :children )
12951299 Dir . children ( path , **opts )
Original file line number Diff line number Diff line change @@ -756,6 +756,23 @@ def test_remove_entry_cjk_path
756756 assert_file_not_exist dir
757757 end
758758
759+ def test_remove_entry_multibyte_path
760+ c = "\u00a7 "
761+ begin
762+ c = c . encode ( 'filesystem' )
763+ rescue EncodingError
764+ c = c . b
765+ end
766+ dir = "tmpdir#{ c } "
767+ my_rm_rf dir
768+
769+ Dir . mkdir dir
770+ File . write ( "#{ dir } /#{ c } .txt" , "test_remove_entry_multibyte_path" )
771+
772+ remove_entry dir
773+ assert_file_not_exist dir
774+ end
775+
759776 def test_remove_entry_secure
760777 check_singleton :remove_entry_secure
761778
You can’t perform that action at this time.
0 commit comments