note 20080 added to function.base64-decode

From: Date: Thu, 21 Mar 2002 18:15:45 +0000
Subject: note 20080 added to function.base64-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-28044@lists.php.net to get a copy of this message
I used to do uudecode as a C module, but I've discovered a really fast way to do it in PHP. Here it is: function uudecode($encode) { $b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz0123456789+/"; $encode = preg_replace("/^./m","",$encode); $encode = preg_replace("/\n/m","",$encode); for($i=0; $i<strlen($encode); $i++) { if ($encode[$i] == '`') $encode[$i] = ' '; $encode[$i] = $b64chars[ord($encode[$i])-32]; } while(strlen($encode) % 4) $encode .= "="; return base64_decode($encode); } This is the PHP equivalent to perl's unpack("u",___). That is, you need to strip the 'begin' and 'end' lines from the typical uuencoded file. -- http://www.php.net/manual/en/function.base64-decode.php http://master.php.net/manage/user-notes.php?action=edit+20080 http://master.php.net/manage/user-notes.php?action=delete+20080 http://master.php.net/manage/user-notes.php?action=reject+20080

« previous php.notes (#28044) next »