quoted_printable_decode some words with accent returns �

334 views Asked by At

The question is about PHP function quoted_printable_decode and returns some � ....

Sample (raw before quoted_printable_decode)

<table width=3D"750" border=3D"0" align=3D"center" cellpa=
dding=3D"0" cellspacing=3D"0">
=09=09=09=09=09=09<tr>
=09=09=09=09=09=09<td class=3D"contenu">
=09=09=09=09=09=09=09=09<div class=3D"txt-contenu">
=09=09=09=09=09=09=09=09<p>Chère cliente, Cher client,</p>
=09=09=09=09=09=09=09=09<p>Selon nos dossiers, une personne de votre entrep=
rise a contacté notre Service =E0 la client=E8le récemment, e=
t nous aimerions savoir si elle est satisfaite du service qu’elle a re&cced=
il;u.
=09=09=09=09=09=09=09=09</p>
=09=09=09=09=09=09=09=09<p>
=09=09=09=09=09=09=09=09=09Puisque votre opinion nous tient à c&oeli=
g;ur, nous vous invitons à participer à un sondage rapide com=
prenant sept questions. Trois minutes suffisent pour y répondre!
=09=09=09=09=09=09=09=09</p>

after quoted_printable_decode

      echo quoted_printable_decode($raw);
    
    returns this:     <table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
                                <tbody><tr>
                                <td class="contenu">
                                        <div class="txt-contenu">
                                        <p>Chère cliente, Cher client,</p>
                                        <p>Selon nos dossiers,
 une personne de votre entreprise a contacté notre 
Service � la client�le récemment, et nous aimerions savoir si elle est satisfaite du service qu’elle a reçu.
                                        </p>
                                        <p>
                                            Puisque votre opinion nous tient à cœur, nous vous invitons à participer à un sondage rapide comprenant sept questions. Trois minutes suffisent pour y répondre!

•••• it seems this portion

Service =E0 la client=E8le

returned Service � la client�le

now how can I fix the returned � part ?

1

There are 1 answers

7
Lessmore On

Try to change encoding to UTF-8.

$str = quoted_printable_decode($str);
$str = iconv(mb_detect_encoding($str, 'ISO-8859-1, ISO-8859-2'), 'UTF-8', $str);
echo $str;

Use mb_detect_encoding to detect current encoding, then change to UTF8 by iconv