开发者

Ruby 1.9.2 Find.find encoding

开发者 https://www.devze.com 2023-02-04 18:43 出处:网络
I know that you can do Dir.entries(\'.\', {:enco开发者_Go百科ding => \'utf-8\'}) and it works properly, but I can\'t find any way to force the encoding when doing Find.find. On Windows, the first m

I know that you can do Dir.entries('.', {:enco开发者_Go百科ding => 'utf-8'}) and it works properly, but I can't find any way to force the encoding when doing Find.find. On Windows, the first method correctly reads a filename of 舦舨.txt, and doing File.file? on the value returns true. However, doing Find.find returns ??.txt, even though ruby says its encoding is utf-8. Also, File.file? returns false.

Is there no way to set the encoding on Find.find?


Instead of

Find.find(dir)

I found

Find.find(dir.encode('utf-8'))

works

0

精彩评论

暂无评论...
验证码 换一张
取 消