0

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 ?

Jintor
  • 607
  • 8
  • 32

1 Answers1

1

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

Lessmore
  • 1,061
  • 1
  • 8
  • 12
  • it worked but only for a small portion `Service à la clientèle`, but for the rest, it gives this : Chère cliente, Cher client, 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. Puisque votre opinion nous tient à cœur, nous vous invitons à participer à un sondage rapide comprenant sept questions. Trois minutes suffisent pour y répondre! – Jintor Dec 09 '20 at 17:27
  • @Jintor Do you know what is original encoding? – Lessmore Dec 09 '20 at 17:36
  • in this sample, I see but this sample seems mixted... For this sample, I patched it with `$string = str_ireplace('=E0','à',$string); $string = str_ireplace('=E8','è',$string);` before the quoted_printable_decode... is ther a list or table somewhere of all quote_printables ? – Jintor Dec 09 '20 at 17:45
  • I found a list https://en.wikipedia.org/wiki/List_of_Unicode_characters in section "Latin-1 Supplement" were I see U+00E8 (is the qprint for =E8)... etc – Jintor Dec 09 '20 at 18:06
  • Try this: `$str = quoted_printable_decode($str); $str = iconv('UTF-8','ASCII//TRANSLIT//IGNORE',$str);` – Lessmore Dec 09 '20 at 19:19
  • this one removes ALL accents :( `Chere cliente, Cher client, Selon nos dossiers, une personne de votre entreprise a contacte notre Service la clientle recemment, et nous aimerions savoir si elle est satisfaite du service qu'elle a reçu.` – Jintor Dec 10 '20 at 00:38
  • I tested `$str = iconv('UTF-8','ASCII//TRANSLIT//IGNORE',$str);` on regular strings that doesn't have quoted printables and I find it actually very helpfull for some other situations were I need to remove accents ;) – Jintor Dec 10 '20 at 00:52