function decode_mime_string ($string) {
$pos = strpos($string, =?);
if (!is_int($pos)) {
return $string;
}
$preceding = substr($string, 0, $pos); // save any preceding text
$search = substr($string, $pos+2, 75); /* the mime header spec says this is the longest a single encoded word can be */
$d1 = strpos($search, ?);
if (!is_int($d1)) {
return $string;
}
$charset = substr($string, $pos+2, $d1);
$search = substr($search, $d1+1);
$d2 = strpos($search, ?);
if (!is_int($d2)) {
return $string;
}
$encoding = substr($search, 0, $d2);
$search = substr($search, $d2+1);
$end = strpos($search, ?=);
if (!is_int($end)) {
return $string;
}
$encoded_text = substr($search, 0, $end);
$rest = substr($string, (strlen($preceding . $charset . $encoding . $encoded_text)+6));
switch ($encoding) {
case q:
case q:
$encoded_text = str_replace(_, %20, $encoded_text);
$encoded_text = str_replace(=, %, $encoded_text);
$decoded = urldecode($encoded_text);
if (strtolower($charset) == windows-1251) {
$decoded = convert_cyr_string($decoded, w, k);
}
break;
case b:
case b:
$decoded = urldecode(base64_decode($encoded_text));
if (strtolower($charset) == windows-1251) {
$decoded = convert_cyr_string($decoded, w, k);
}
break;
default:
$decoded = =? . $charset . ? . $encoding . ? . $encoded_text . ?=;
break;
}
return $preceding . $decoded . decode_mime_string($rest);
} // decode_mime_string()
试试这段代码吧,解码mime 的-PHP教程,PHP应用
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 试试这段代码吧,解码mime 的-PHP教程,PHP应用
相关推荐
-      PHP源码-利用 QQWry.Dat 实现 IP 地址高效检索
-      Php高手带路–问题汇总解答[2]
-      PHPQQ编程(2):取QQ在线状态
-      php5手动最简安装方法
-      福利彩票幸运号码自动生成器
-      PHP开发利器-PRADO 1.6
-      在Apache 服务器上启用PHP支持
-      Windows2000_pro下安装Apache+PHP4+My