最好的邮件编码解码类,再没有比这个好的了!贴不下了(1)

作者:袖梨 2022-07-02
class mime_decode {
    var $content     = Array();
    function mime_encode_headers($string) {
        if($string == "") return;
        if(!eregi("^([[:print:]]*)$",$string))
       $string = "=?ISO-8859-1?Q?".str_replace("+","_",str_replace("%","=",urlencode($string)))."?=";
        return $string;
    }
    function decode_mime_string($string) {
        if(($pos = strpos($string,"=?")) === false) return $string;
        while(!($pos === false)) {
       $newresult .= substr($string,0,$pos);
       $string = substr($string,$pos+2,strlen($string));
       $intpos = strpos($string,"?");
       $charset = substr($string,0,$intpos);
       $enctype = strtolower(substr($string,$intpos+1,1));
       $string = substr($string,$intpos+3,strlen($string));
       $endpos = strpos($string,"?=");
       $mystring = substr($string,0,$endpos);
       $string = substr($string,$endpos+2,strlen($string));
       if($enctype == "q") {
           $mystring = str_replace("_"," ",$mystring);
           $mystring = $this->decode_qp($mystring);

相关文章

精彩推荐