【发布时间】:2013-10-15 16:49:07
【问题描述】:
我有somefile,我想使用base64对其进行编码
File.open('data/somefile.edf').read.encoding
=> #<Encoding:UTF-8>
base64_string = Base64.encode64(open("data/somefile.edf").to_a.join)
然后我想解码那个文件
file = open('new_edf.edf', 'w') do |file|
file << Base64.decode64(base64_string)
end
但我得到一个错误:
Encoding::UndefinedConversionError: "\xE1" from ASCII-8BIT to UTF-8
from (pry):22:in `write'
【问题讨论】:
-
只是出于好奇......我的解决方案是否有助于解决问题?
标签: ruby encoding base64 encode