[#47548] [ruby-trunk - Feature #8696][Open] Process.setproctitle — "znz (Kazuhiro NISHIYAMA)" <redmine@...>

13 messages 2013/07/27

[#47559] [ruby-trunk - Bug #8711][Open] 最近NoMemoryErrorが多い — "naruse (Yui NARUSE)" <naruse@...>

13 messages 2013/07/31

[ruby-dev:47530] [ruby-trunk - Feature #8657][Open] Make Find.find respect the encodings of arguments

From: "ktsj (Kazuki Tsujimoto)" <kazuki@...>
Date: 2013-07-19 10:53:00 UTC
List: ruby-dev #47530
Issue #8657 has been reported by ktsj (Kazuki Tsujimoto).

----------------------------------------
Feature #8657: Make Find.find respect the encodings of arguments
https://bugs.ruby-lang.org/issues/8657

Author: ktsj (Kazuki Tsujimoto)
Status: Open
Priority: Normal
Assignee: 
Category: lib
Target version: next minor


=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



-- 
http://bugs.ruby-lang.org/

In This Thread

Prev Next