Ruby, unable to delete file on windows - I suspect encoding problem
Similar to this question - now I can create file "Austra Skujytė.txt" but I am unable to delete it. I suspect that it is caused by ė as other files with fancy characters are also affected. AFAIK there is no way to specify encoding like in file opening:
开发者_高级运维out=File.open("#{file}", "a:UTF-8")
How can I fix it?
To delete the file, try using the short 8.3 filename; e.g.,
File.delete("AUSTRA~1.TXT")
You can convert a long filename to the short format using FFI:
https://github.com/ffi/ffi/wiki/Windows-Examples#wiki-intermediate
It's a bit hacky, but it may be what you need.
精彩评论