IÃ'm sorry, but your code is incorrect, and it cannot be done correctly either. As I explained, the encoding rules depend on the grammar of the paricular header field. Use of the _text functions is correct only for headers which grammar declare them to be "text". Headers which instead use the "phrase" non-terminal in their grammar (such as the "From:" and "To:" headers) need to be treated differently. There is even an example in RFC1522 which is not correctly decoded by your class.