ruby 解码字符串(postfilter x-esc-entities)
ruby decode string (postfilter x-esc-entities)
如何通过 ruby 解码字符串 \xC3\xE0\xEB\xE8\xED\xE0.JPG
?
解码成功示例(https://2cyr.com/decode/?lang=en)
尝试 force_encoding
输入字符串,然后转换为 UTF-8。
str = "\xC3\xE0\xEB\xE8\xED\xE0.JPG"
str.force_encoding("cp1251").encode("utf-8", undef: :replace)
=> "Галина.JPG"
如何通过 ruby 解码字符串 \xC3\xE0\xEB\xE8\xED\xE0.JPG
?
解码成功示例(https://2cyr.com/decode/?lang=en)
尝试 force_encoding
输入字符串,然后转换为 UTF-8。
str = "\xC3\xE0\xEB\xE8\xED\xE0.JPG"
str.force_encoding("cp1251").encode("utf-8", undef: :replace)
=> "Галина.JPG"