Is there a way to decode q-encoded strings in Ruby?

前端 未结 6 708
星月不相逢
星月不相逢 2021-01-13 16:05

I\'m working with mails, and names and subjects sometimes come q-encoded, like this:

=?UTF-8?Q?J=2E_Pablo_Fern=C3=A1ndez?=

Is there a way t

6条回答
  •  独厮守ぢ
    2021-01-13 16:29

    This is a pretty old question but TMail::Unquoter (or its new incarnation Mail::Encodings) does the job as well.

    TMail::Unquoter.unquote_and_convert_to(str, 'utf-8' )
    

    or

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

提交回复
热议问题