Feature #8657
closedMake Find.find respect the encodings of arguments
Description
=begin
== 概要
Find.findが返すパス名は常にfilesystem encodingとなっていますが
任意のencodingを指定できるようにすることを提案します。
== ユースケース
日本語Windowsではfilesystem encodingはWindows-31Jとなっています。
このため、Windows-31Jに存在しない文字を含むファイル名があった場合に
正しいパス名を取得できないという問題が起きます。
D:>dir /s /b D:\t
D:\t\♠ (U+2660)
D:\t\♠\a.txt
D:>ruby -v -rfind -e "p Find.find('D:/t'.force_encoding('utf-8')).to_a"
ruby 2.1.0dev (2013-07-19 trunk 42058) [i386-mingw32]
["D:/t", "D:/t/?"]
== API
パス名を扱う他のAPIにおけるencoding指定の方式には以下の2つがあるようです。
([ruby-list:44877]にこの辺りの議論がありますが結論が見あたりませんでした)
- encodingオプションを明示的に渡す(e.g. Dir.entries)、
- 引数として与えた文字列のencodingを暗黙的に利用する(e.g. Dir.glob)
ファイルシステムごとにencodingが別々である可能性を考慮しなければならないこと(#2154)、
Find.findは引数として複数のパスをまとめて受け取れることから
後者の形にするのがよさそうに思います。
== 実装
lib/find.rbに対するパッチを添付します。
=end
Files
        
           Updated by ktsj (Kazuki Tsujimoto) about 12 years ago
          Updated by ktsj (Kazuki Tsujimoto) about 12 years ago
          
          
        
        
      
      現在findのメンテナがいないようなのであわせて立候補します。
        
           Updated by ktsj (Kazuki Tsujimoto) about 12 years ago
          Updated by ktsj (Kazuki Tsujimoto) about 12 years ago
          
          
        
        
      
      - Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r42866.
Kazuki, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- 
lib/find.rb (Find.find): respect the encodings of arguments. 
 [ruby-dev:47530] [Feature #8657]
- 
test/test_find.rb: add tests. 
        
           Updated by ktsj (Kazuki Tsujimoto) about 12 years ago
          Updated by ktsj (Kazuki Tsujimoto) about 12 years ago
          
          
        
        
      
      =begin
[[ruby:DevelopersMeeting20130831Japan]]でacceptされたのでコミットしました。
=end