ruby decode string(postfilter x-esc-entities)

时间:2016-12-19 21:15:47

标签: ruby decode

如何通过ruby解码字符串\xC3\xE0\xEB\xE8\xED\xE0.JPG

成功解码的示例(https://2cyr.com/decode/?lang=enSuccessful decoding

1 个答案:

答案 0 :(得分:2)

在输入字符串上尝试force_encoding,然后转换为UTF-8。

str = "\xC3\xE0\xEB\xE8\xED\xE0.JPG"
str.force_encoding("cp1251").encode("utf-8", undef: :replace)
=> "Галина.JPG"