我收到以下错误:
Encoding::UndefinedConversionError: "\x81" from ASCII-8BIT to UTF-8
在Ruby中1.8.7以下的所有工作,所以我觉得这与Ruby 1.9的如何处理编码做的,但我不太知道如何解决它。 我目前使用Ruby 1.9.3。
decode_base64_content = Base64.decode64(content) File.open("index.txt", "w") do |f| f.write(decode_base64_content) end
其中的内容是这样的:
CgcZAAEAAABQcmVzZW50YXRpb24RMQAGSUIyQjdCNjBCLUZBRTMtMjVGMS1DQ0E1LTM1REM4NjBC
MDlCRgYCBklBMjk2OTQ4MC0yMkQyLURENzMtQUY5Ni1DNURDMDIyQTVFRjkGBAZJNUJCRTI3REYt
Q0QyRC03NkY0LTk1MUMtQzYxRkYxQjgxN0Y4BgYGSTg0QjM3M0FGLTVFNjEtMkMwMy1DMTBCLUNB
MUZCMDY0Q0NERQYIBkkwOTIwNDRBRC02QTQ5LTg0NzEtMzc5QS0yRjQxMzU2MUY0OUQGCgZJODlC
NDczOTUtOTk1MS01OTk1LTk4NDctNkU1NjI4RjhGNjYzBgwGSThCQ0RFM0VDLUMyREItMDkyNy1G
NTFFLTJGNDE4OEMzNURDMwYOBklGMDk5QkRDOC1GOEFDLTg1QjEtMjgzMC0yRjQ5RkZFMDFCNUEG
EAZJNTJCOEQ3RUItMzZEQi1CMjNELUU2MTYtMkY0QjUxNDIwMjBFBhIGSUM2RjkzNjgwLTFBNjMt
NzU5Qi0yOEE5LTUwMDc2NjZCOEYyNgYUBkk2MDIwRjg4Ni1BQTk4LTRBNDQtQjZGNS1DNDAyMTMz
NzEzOEQGFgZJRDFEMjcxMzYtQTkwQy0xRDBBLTc4RjAtQ0ExRUFCQzgzRUE1BhgGSUZBRDQzMjI1
LTUwODctNENEMy1ENjkzLUQ4Qzg0NDc3RTMyRAYaBklFMjc5NjA5Mi0xNUYzLUY4NkItMEFBQi0x
MUEzQjIwNEFBRTIGHAZJNERFNEYzNUItQzAyNy1DOTQ1LTY2MzUtMDE4NTZDRTdBMDM3Bh4GSUM4
NjA4RkI4LUI4RDEtMjM5RS04ODY4LUNBMjIzNUUwNjk5MAYgBkk4QjcxOEFDRi03NEE0LTA4REQt
QzZENC1DQTEyNDQwRTkzOUYGIgZJQjA3NTk0OEMtQzA3MS0wQTQ3LTYxNDQtNEU1OUIwN0QwQ0VF
BiQGSUM2M0VFQkU1LUZFOEEtRUVDMC1GNDFFLTc3QTI3Qzg2RDE1OAYmBkk5QkQ2M0NEQi02NDg2
LTM2OUQtMTY0NS0xMDIzMTQ5Njk1OUQGKAZJOTI3NDUzNDEtRUYzRC04MEU1LUZDQkUtQ0EyMTZG
Q0FGRTcyBioGSUI3MzlFMTBFLTk2M0QtMDA0Ny1EMkU1LUNBMjA2ODM2MjZFNgYsBkk4RUY5QkZB
Ni0wNDAyLTQwQUQtRjAxQi0xMTRBNDBFODMwRjMGLgZJQjY2N0YxODktNzQ4My05RkE4LTYwMDkt
即持续〜3000线。
我该如何解决这个转换错误? 上面的代码片段的作品,但在某处3000线,我认为以base64解码方法使用无效编码。 谢谢!