热门标签 | HotTags
当前位置:  开发笔记 > 开发工具 > 正文

试试这段代码吧,解码mime的

functiondecode_mime_string($string){$posstrpos($string,?);if(!is_int($pos)){return$string;}$precedingsubstr($string,0,$pos);//saveanyprecedingtext$searchsubstr(

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()

推荐阅读
author-avatar
好好_haohao_100
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有