Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : IMAP, POP3 and NNTP Functions : imap_qprint

imap_qprint

Convert a quoted-printable string to an 8 bit string (PHP 4, PHP 5)
string imap_qprint ( string string )


Code Examples / Notes » imap_qprint

bernard

This function seems to have a bug, when the quoted-printable string contains a "=" without the HEX code of a Character.
I use the regular quoted_printable_decode instead.


bletous

Some mails are encoded in bad quoted printable format:
I use this function to decode the qprint:
for($i=0;$i<256;$i++)
{
$c1=dechex($i);
if(strlen($c1)==1){$c1="0".$c1;}
$c1="=".$c1;
$myqprinta[]=$c1;
$myqprintb[]=chr($i);
}
function decode($data,$code)
{  
if(!$code){return imap_utf7_decode($data);}
if($code==0){return imap_utf7_decode($data);}
if($code==1){return imap_utf8($data);}
if($code==2){return ($data);}
if($code==3){return imap_base64($data);}
if($code==4){return imap_qprint(str_replace($myqprinta,$myqprintb,($data)));}
if($code==5){return ($data);}
}


tonitester

If you don't have access to the imap_qprint function and you have to encode URL Decoded and Quoted Printable Strings you receive by Mail try this simple function. But if you don't receive URL Decoded data and the string doesn't contain an = you better use http://www.php.net/manual/en/function.quoted-printable-decode.php
function decode_qprint($str){
$arr= array("A","B","C","D","E","F");
while (list(, $var) = each($arr)) {
$i=0;
while ($i <=9){
$str=str_replace("=".$var.$i,"%".$var.$i,$str);
$i++;}
$arr2 = array("A","B","C","D","E","F");
while (list(, $val) = each($arr2)) {
$str=str_replace("=".$var.$val,"%".$var.$val,$str);}}
$str = urldecode($str);
$str = utf8_encode($str);
return $str;}
$s2d='=F6=D6=DF=C4=E4=DC=FC=A9=AE';
$2s2d='%F6';
$output = decode_qprint($s2d);
$output2 = decode_qprint($2s2d);
echo $output;
echo $output2;


jdr

$subject=utf8_decode(imap_utf8($subject));
works instead of imap_qprint on php 4.2.0 (win32)


Change Language


Follow Navioo On Twitter
imap_8bit
imap_alerts
imap_append
imap_base64
imap_binary
imap_body
imap_bodystruct
imap_check
imap_clearflag_full
imap_close
imap_createmailbox
imap_delete
imap_deletemailbox
imap_errors
imap_expunge
imap_fetch_overview
imap_fetchbody
imap_fetchheader
imap_fetchstructure
imap_get_quota
imap_get_quotaroot
imap_getacl
imap_getmailboxes
imap_getsubscribed
imap_header
imap_headerinfo
imap_headers
imap_last_error
imap_list
imap_listmailbox
imap_listscan
imap_listsubscribed
imap_lsub
imap_mail_compose
imap_mail_copy
imap_mail_move
imap_mail
imap_mailboxmsginfo
imap_mime_header_decode
imap_msgno
imap_num_msg
imap_num_recent
imap_open
imap_ping
imap_qprint
imap_renamemailbox
imap_reopen
imap_rfc822_parse_adrlist
imap_rfc822_parse_headers
imap_rfc822_write_address
imap_savebody
imap_scanmailbox
imap_search
imap_set_quota
imap_setacl
imap_setflag_full
imap_sort
imap_status
imap_subscribe
imap_thread
imap_timeout
imap_uid
imap_undelete
imap_unsubscribe
imap_utf7_decode
imap_utf7_encode
imap_utf8
eXTReMe Tracker