[英]Character set issues in filepath using ruby on XP
I'm trying to do a File.exist?(file)
but my ruby script doesn't find the file because of \\, spaces, - and . 我正在尝试做
File.exist?(file)
但是我的ruby脚本由于\\,空格,-和。而找不到该文件。 in the filepath. 在文件路径中。 I'm a beginner in ruby and need some help to fix this.
我是红宝石的初学者,需要一些帮助来解决此问题。
I assume it has to do with your OS, more then with Ruby. 我认为这与您的OS有关,而与Ruby有关。
file tèst.rb: 文件tèst.rb:
puts "Hello"
puts "smørebrød"
used in irb: 用于irb:
irb(main):001:0> require "tèst.rb"
Hello
smørebrød
Ruby can include a file with name tèst.rb just fine. Ruby可以包含名称为tèst.rb的文件。
irb(main):005:0> f = File.new("ÅÄÖ.txt")
irb(main):006:0> f.each {|l| p l }
"\"Hej Verden\"\n"
loading a file with your requested characters and printing its lines ( pl
) works just fine. 用您要求的字符加载文件并打印其行(
pl
)效果很好。 I am running ruby 1.8.7
on Ubuntu Linux
. 我在
Ubuntu Linux
上运行ruby 1.8.7
。 That is a rather old Ruby. 那是一个相当老的Ruby。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.