/**universal * Encoder une chaine compatible "ENCODING=QUOTED-PRINTABLE" - cette chaine est dcodable avec la fonction "quoted_printable_decode()" * ex: quoted_printable_encode(ut8_encode("c'est quand l't ?")) -> "c'est quand l'=C3=A9t=C3=A9 ?" * * @author Thomas Pequet / Memotoo.com * @version 1.1 * @param string:string Chaine * @return Chaine encode */ function quoted_printable_encode($string) { // Fonction qui ajoute au tableau de valeurs un "=" devant if (!function_exists("array_values_quoted_printable")) { function array_values_quoted_printable($tab) { $tabValues = array_values($tab); for ($i=0;$i "09", "\n" => "0A", "\r" => "0D", // " " => "20", "\xA0" => "A0", "" => "A1", "" => "A2", "" => "A3", "" => "A4", "" => "A5", "" => "A6", "" => "A7", "" => "A8", "" => "A9", "" => "AA", "" => "AB", "" => "AC", "" => "AE", "" => "AF", "" => "B0", "" => "B1", "" => "B2", "" => "B3", "" => "B4", "" => "B5", "" => "B6", "" => "B7", "" => "B8", "" => "B9", "" => "BA", "" => "BB", "" => "BC", "" => "BD", "" => "BE", "" => "BF", "" => "C0", "" => "C1", "" => "C2", "" => "C3", "" => "C4", "" => "C5", "" => "C6", "" => "C7", "" => "C8", "" => "C9", "" => "CA", "" => "CB", "" => "CC", "" => "CD", "" => "CE", "" => "CF", "" => "D0", "" => "D1", "" => "D2", "" => "D3", "" => "D4", "" => "D5", "" => "D6", "" => "D7", "" => "D8", "" => "D9", "" => "DA", "" => "DB", "" => "DC", "" => "DD", "" => "DE", "" => "DF", "" => "E0", "" => "E1", "" => "E2", "" => "E3", "" => "E4", "" => "E5", "" => "E6", "" => "E7", "" => "E8", "" => "E9", "" => "EA", "" => "EB", "" => "EC", "" => "ED", "" => "EE", "" => "EF", "" => "F0", "" => "F1", "" => "F2", "" => "F3", "" => "F4", "" => "F5", "" => "F6", "" => "F7", "" => "F8", "" => "F9", "" => "FA", "" => "FB", "" => "FC", "" => "FD", "" => "FE", "" => "FF", ); // Cas particulier -> remplacer tous les "=" en premier $string = str_replace("=", "=3D", $string); // Cas particulier de l'uft8 -> encod en "quoted_printable" le caractre aprs "", "", "", "", "", "" pour grer tous les caractres autres que ceux ci-dessus (ex:"^" -> 0x88) $tailleTmp = strlen($string); $i = 0; while ($i<$tailleTmp) { if (($string[$i]=="" || $string[$i]=="" || $string[$i]=="" || $string[$i]=="" || $string[$i]=="" || $string[$i]=="") && $i+1<$tailleTmp && $string[$i+1]!=" " && $string[$i+1]!="") { $strTmp = strtoupper(bin2hex($string[$i+1])); if (strlen($strTmp)==2) { // Dcaler les caractres de 2 for ($j=$tailleTmp-1;$j>$i;$j--) { $string[$j+2] = $string[$j]; } // Remplacer par la valeur "quoted_printable" $string[$i+1] = "="; $string[$i+2] = $strTmp[0]; $string[$i+3] = $strTmp[1]; $i += 2; $tailleTmp += 2; } } $i++; } $string = str_replace(array_keys($tabStr), array_values_quoted_printable($tabStr), $string); return $string; }