How to decode an object received via Net :: IMAP, which is in UTF8? (Ruby)

I am using Net :: IMAP.fetch to retrieve some messages from Gmail. However, when I receive a message with a UTF8 object (i.e. In Cyrillic), I get something like this:

=?UTF-8?B?0KHRgNC/0YHQutC4INGE0L7RgNGD0Lwg0YLRgNCw?= =?UTF-8?B?0LbQuCDQuNC30LHQvtGA0L3QuCDQvNCw0YLQtdGA0Lg=?= =?UTF-8?B?0ZjQsNC7INC4INC90LAg0ZvQuNGA0LjQu9C40YY=?= =?UTF-8?B?0LggLSBjaXJpbGFjZSB0ZXN0?=

How to convert the specified string to UTF8?

NOTE: this is for ruby ​​1.8.7

+5
source share
1 answer

Answer:

Mail::Encodings.unquote_and_convert_to( string, 'utf-8' )

The fact is that the encoding of email objects is the "QUOTED-PRINTABLE" encoding (the default for Gmail).

+3
source

All Articles