开发者

Is there any way to make FileUtils work with UTF-8 file names?

开发者 https://www.devze.com 2023-03-03 02:17 出处:网络
I have created this Ruby (1.9.2) code and the last line fails: File.open(\"test äöü.txt\", \"w+\").close

I have created this Ruby (1.9.2) code and the last line fails:

File.open("test äöü.txt", "w+").close
File.chmod(0644, "test äöü.txt")
FileUtils.chmod(0644, "test äöü.txt") # FAILS

The message is:

Errno::ENOENT (No such file or directory - C:/.../test ├ñ├Â├╝.txt):

Althoug the FileUtil.chmod calls File.chmod eventually, for some reason it messes with the file name along the way.

Normally I'd just use File instead of FileUtils, but unfortunately I'm using a gem which uses FileUtils and I'm hoping I can avoid chan开发者_如何学Cging the gem source.

Does anyone know why this is happening? The source of FileUtils.chmod looks straightforward but I still can't figure out the problem. Is there any way to monkey-patch FileUtils to make it work?

Thanks.


It appears to be a Windows only problem, related to issue 1685.

Hopefully someone with a good understanding of encoding issues & windows can enlighten you as to what can be done until it is resolved.

0

精彩评论

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