Ruby转换文件编码的问题

Python015

Ruby转换文件编码的问题,第1张

很容易

使用Ruby 内置的 Iconv类就可以做到了 ,详细的请参考ruby参考手册

这里给出一个样例

require "iconv"

line = File.open('c:\unicode.txt',"w")

result = Iconv.iconv("GB2312","UTF-8",line)

result.puts()

Zip::ZipFile::open("D:/test.zip") do |zfile|

zfile.each do |zent|

puts zent

puts zent.is_directory # 判断是不是目录 是目录你就创建一个就行了!

end

end