note 11405 deleted from ref.mail by jimw

From: Date: Thu, 01 Nov 2001 19:58:52 +0000
Subject: note 11405 deleted from ref.mail by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20005@lists.php.net to get a copy of this message
For the so boring Subject: <ISO-8859-1?B?VGVzd> in many php mailing lists... here's a useful (improvable!) function: function iso2text($str) { $arr = array(); $pieces = array(); // verify $str to be a ... if((substr($str, 0,2) != "=?") | (substr($str,-2) != "?=")) { $arr[0] = 1; $arr[1] = $str; return $arr; } $part = explode ("?", substr($str, 2, strlen($str)-4)); // printf("Parts= %s, %s, %s <P><P>", $part[0], $part[1], $part[2]); $charset = strtoupper($part[0]); $encoding = strtoupper($part[1]); $encoded = $part[2]; if( $charset != "ISO-8859-1") { $arr[0] = 2; $arr[1] = $str; return $arr; } switch( $encoding) { case "Q": $arr[0] = 0; $arr[1] = quoted_printable_decode($encoded); $arr[2] = $charset; $arr[3] = $encoding; break; case "B": $arr[0] = 0; $arr[1] = base64_decode($encoded); $arr[2] = $charset; $arr[3] = $encoding; break; default: $arr[0] = 3; $arr[1] = $str; } return $arr; }

« previous php.notes (#20005) next »