I would like a function or some source code that can uudecode a string. This can be accomplished in Perl easily with $decoded = unpack("u", $encoded); Encoding data with: $encoded = pack("u", org_string);
I have found that PHP has a pack function but did not include a "u" (uudecode) option. I found an example that supposedly works, but after testing it, it does not decode properly. Here is the example:
function uudecode($encode)
{
$b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm nopqrstuvwxyz0123456789+/";
$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 ($encode);
}
I found a good site that explains in depth how uuencoding works, it is at
http://www.drbob42.com/books/uucode.htm
There is a Pascal example that I have not yet tried converting into PHP.
The character set used for decoding was different from the example, here are the characters from the web site.
$b64chars="`!\"#$%&'()*+,-./0123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_";
I tried substituting the characters into the function and it also did not work.
Walter G.