|
Posted by Alvaro G. Vicario on 08/03/06 17:39
*** softap@gmail.com escribió/wrote (3 Aug 2006 02:03:40 -0700):
> This works fine normally, but occasionally an email may contain the
> name and address of somebody in Europe, and when this happens the
> character set of the email changes from "us-ascii" to "ISO 8859-1" and
> this confuses my parsing code, because I get characters like =E4 and
> =E5 for some of the accented european characters in people's name or
> address, and where there would normally be a row of "equals" characters
> which is used as a separator line in the email, I get =3D=3D=3D etc.
This cute function was published in this group some weeks ago:
<?
function quoted_word_callback($m) {
switch($m[2]) {
case 'Q': case 'q': return quoted_printable_decode($m[3]);
case 'B': case 'b': return base64_decode($m[3]);
}
}
$s = "OLED & =?ISO-8859-1?Q?br=E4nsleceller?=";
echo preg_replace_callback('/=\?(.*)\?([BQ])\?(.*)\?=/U',
'quoted_word_callback', $s);
?>
Hope it helps.
http://groups.google.com/group/comp.lang.php/msg/1687691dd266c990
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Navigation:
[Reply to this message]
|