Last active
January 13, 2017 16:36
-
-
Save ryo-utsunomiya/aa46453a3a49e71147856f2a0bf87b1f to your computer and use it in GitHub Desktop.
[PHP] mb_decode_mimeheader() は Quoted-printable なヘッダのデコードに失敗する ref: http://qiita.com/ryo511/items/82022f836f0fe033020b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=?utf-8?Q?=E3=83=86=E3=82=B9=E3=83=88This_is_valid_subject_of_MIM?= | |
=?utf-8?Q?E_header?= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$subject = <<<TXT | |
=?utf-8?Q?=E3=83=86=E3=82=B9=E3=83=88This_is_valid_subject_of_MIM?= | |
=?utf-8?Q?E_header?= | |
TXT; | |
var_dump(mb_decode_mimeheader($subject)); // string(45) "テストThis_is_valid_subject_of_MIME_header" | |
var_dump(imap_utf8($subject)); // string(45) "テストThis is valid subject of MIME header" | |
var_dump(decode_mime_header($subject)); // string(45) "テストThis is valid subject of MIME header" | |
function decode_mime_header($str) { | |
$decoded = ''; | |
$parts = imap_mime_header_decode($str); | |
foreach ($parts as $part) { | |
$decoded .= $part->text; | |
} | |
return $decoded; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decode_mimeheader($str) { | |
return mb_decode_mimeheader(str_replace('_', '=20', $str)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decode_mimeheader($str) { | |
return mb_decode_mimeheader(str_replace('_', '=20', $str)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment