Page 1 of 1
Uuencode
Posted: Thu Apr 14, 2005 12:43 pm
by spacebiscuit
Hi,
Does anyone know anything about uuencoding?
I am looking for a class that will encode a binary file. There are some uuencode functions within php but they are for strings as far as I know.
Thanks,
Rob.
Posted: Thu Apr 14, 2005 1:10 pm
by Chris Corbyn
What is this uuencoding?
Looks the functions are binary safe by the way
php.net wrote:
string convert_uuencode ( string data )
convert_uuencode() encodes a string using the uuencode algorithm.
Uuencode translates all strings (including binary's ones) into printable characters, making them safe for network transmissions. Uuencoded data is about 35% larger than the original.
So untested but....
Code: Select all
$filename = './dir/file.ext';
$string_data = file_get_contents($filename);
$encoded_data = convert_uuencode($string_data);
Posted: Thu Apr 14, 2005 4:27 pm
by spacebiscuit
Hi,
Uuencode I believe is an encoding used for mail attachments within emails. The Uuencode function within php is for strings - I need one that will operate on a file. I have done a thorough search and cannot find anything. I may need to encode the file with a stand alone application I think.
I'll let you know.
Rob.
Posted: Thu Apr 14, 2005 9:24 pm
by spacebiscuit
Hi,
It seems that it isn't possible to encode a file with uuencode. So anyway i got around this problem by encoding my files with a standalone application.
Then when I attach and send my mail to newsgroup everything works fine.
Not the most elegant solution but it works and I am happy!
Rob.
Posted: Thu Apr 14, 2005 10:33 pm
by feyd
I don't see why it wouldn't be possible to have php do the encoding.. I remember uuencode being a fairly simple algorithm.
Posted: Fri Apr 15, 2005 5:23 am
by spacebiscuit
I thnk php only works on strings and not files. When I encoded with the php function the resulting file was incorrect. The file structure was not correct. Images encoded with uuencode should have the following format:
begin 0666 1.jpg
M_]C_X``02D9)1@`!`0$`2`!(``#_X0EF17AI9@``24DJ``@````*``\!`@`&
M````A@```!`!`@`.````C````!(!`P`!`````0```!H!!0`!````F@```!L!
end
That is they start with 'begin .......' finsh with 'end' and each line inbetween starts with an M. Try it on a file with the php function and it doesn't have this structure.
Rob.