I read mail from the box using the "mail" heme. There is a plug when reading the body of the letter:
mail.body.decoded Falls with an error:
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT I add:
mail.body.decoded.force_encoding("UTF-8") I receive:
ArgumentError: invalid byte sequence in UTF-8 Is it possible to somehow cut out any readable characters from this line and / or somehow convert it to UTF-8? It works this way, but the entire text is replaced with questions (?):
mail.body.decoded.encode("UTF-16be", :invalid => :replace, :replace => "?").encode('UTF-8') I would like to remove only unreadable characters.
UPDATE The letter encoding for this is UTF-8:
{"charset"=>"utf-8", "format"=>"fixed"} {"charset"=>"utf-8"} UPDATE2
mail.body.decoded.bytes:
228 207 194 210 217 202 32 196 197 206 216 46 13 10 13 10 13 10 243 208 193 211 201 194 207 46 32 238 197 212 44 32 206 197 32 203 210 201 212 201 222 206 207 46 32 235 193 203 32 212 207 204 216 203 207 32 196 207 208 201 219 213 32 207 212 208 210 193 215 203 213 32 45 32 211 207 207 194 221 213 46 13 10 13 10 13 10 13 10 13 10
mail.body.decoded.encodingwhat shows? - D-sidemail.body.decoded.bytes, if there is nothing secret in the letter :) - D-side