I am trying to encode โ (right arrow, → or unicode 2192 hex) into the subject line of an email message.
When I use php mb_encode_mimeheader() , I get a different value when I do the same with Thunderbird or Gmail. But when the message generated by php arrives, the character is not displayed properly. In addition, PHP mb_decode_mimeheader() works with exiting PHP, but not for decoding content from other email sources.
As a hex dump, I designed the UTF-8 arrow representation
<?php $rarr = "\xe2\x86\x92"; mb_encode_mimeheader($rarr, 'UTF-8'); // =?UTF-8?B?w6LChsKS?= // whereas Tbird and Gmail produce: =?UTF-8?B?4oaS?= // and more manually: '=?UTF-8?B?' . base64_encode($rarr).'?='; // =?UTF-8?B?4oaS?=
PHP coding is output in Thunderbird and Gmail as: รข
I am completely confused by the behavior of PHP, as it does not seem to give standard results.
How can I get PHP to encode the message header value of UTF-8 so that it is properly decoded by email clients?
source share