PHP: MIME header encoding
Hi all,
I'm struggling with an issue and I need assistance: I need to convert HTML encoded text to mime header encoding using PHP, but it's not working for me. Original text in Hebrew: הודעה בעברית HTML Entities text (I replaced the & by _ for it to be properly displayed here): _#1492;_#1493;_#1491;_#1506;_#1492; _#1489;_#1506;_#1489;_#1512;_#1497;_#1514; Mime encoded text by Thunderbird (correct): =?UTF-8?B?15TXldeT16LXlCDXkdei15HXqNeZ16o=?= Mime encoded text by the following PHP function (incorrect): PHP Code:
Can anyone identify why my function doesn't generate the correct result? Thanks a lot, David |
Debugging is what you should do
Code:
#!/usr/local/bin/php Code:
in='ה' [hex 2623313439323b] |
I did what you suggested (note that I'm using php-cli and not web).
These are the results I get: Code:
root@server:/usr/local/sbin/phpfilters# ./test_mime.php =?UTF-8?B?15Q=?= I'm not sure what to do with these results. Thanks. |
if unicode is 1492 (#x5D4), then UTF8 is D794, which is indeed '15Q=' in base64
so methinks it 'step2' that does the wrong thing. Documentation of mb_encode_mimeheader suggests setting mb_internal_encoding Add this to the beginning of the script: Code:
mb_internal_encoding ('UTF-8'); |
solved, using another function
Hi,
I need to check your suggestion, but in the mean time, I found another function that works (more complex, though): PHP Code:
Thank you for your help!! David |
Quote:
Thanks again! |
All times are GMT -5. The time now is 03:19 PM. |