PHP Doku:: Konvertiert einen quoted-printable kodierten String in einen 8 Bit String - function.imap-qprint.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzE-Mail-relevante ErweiterungenIMAP, POP3 and NNTPIMAP Funktionenimap_qprint

Ein Service von Reinhard Neidl - Webprogrammierung.

IMAP Funktionen

<<imap_ping

imap_renamemailbox>>

imap_qprint

(PHP 4, PHP 5)

imap_qprintKonvertiert einen quoted-printable kodierten String in einen 8 Bit String

Beschreibung

string imap_qprint ( string $string )

Konvertiert einen quoted-printable String in einen 8 Bit String gemäß » RFC2045, Abschnitt 6.7.

Parameter-Liste

string

Ein quoted-printable kodierter String

Rückgabewerte

Liefert einen 8 Bit String

Siehe auch

  • imap_8bit() - Konvertiert einen 8bit String in einen quoted-printable String


5 BenutzerBeiträge:
- Beiträge aktualisieren...
wese at gmx dot at
11.11.2008 15:52
I just got rid of the loops using a regex.

<?php
function decode_qprint($str) {
   
$str = preg_replace("/\=([A-F][A-F0-9])/","%$1",$str);
   
$str = urldecode($str);
   
$str = utf8_encode($str);
    return
$str;
}
?>

Thanks for sharing!
tonitester at gmx dot net
27.03.2007 16:35
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;
bletous at yahoo dot fr
28.08.2005 2:55
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);}

}
jdr
16.07.2003 18:28
$subject=utf8_decode(imap_utf8($subject));

works instead of imap_qprint on php 4.2.0 (win32)
bernard at bmpsystems dot com
26.02.2000 21:35
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.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)