我正在使用最近添加了Unicode BOM头(U + FEFF)的数据源,而我的rake任务现在被它搞砸了.
我可以跳过前3个字节,file.gets[3..-1]但有没有更优雅的方式来读取Ruby中的文件,无论BOM是否存在,都能正确处理?
file.gets[3..-1]
ruby unicode byte-order-mark file
byte-order-mark ×1
file ×1
ruby ×1
unicode ×1