Python The
Python language supports uuencoding using the codecs module with the codec "uu": For Python 2
(deprecated/sunset as of January 1st 2020): $ python -c 'print "Cat".encode("uu")' begin 666 • 0V%T end $ For Python 3
where the codecs module needs to be imported and used directly: $ python3 -c "from codecs import encode;print(encode(b'Cat', 'uu'))" b'begin 666 \n#0V%T\n \nend\n' $ To decode, pass the whole file: $ python3 -c "from codecs import decode;print(decode(b'begin 666 \n#0V%T\n \nend\n', 'uu'))" b'Cat'
Perl The
Perl language supports uuencoding natively using the pack() and unpack() operators with the format string "u": $ perl -e 'print pack("u","Cat")' • 0V%T Decoding base64 with unpack can likewise be accomplished by translating the characters: $ perl -e 'print unpack("u","#0V%T")' Cat To produce wellformed uuencoded files, you need to use modules, or a little bit more of code:
Encode (oneliner) $ perl -ple 'BEGIN{use File::Basename;$/=undef;$sn=basename($ARGV[0]);} $_= "begin 600 $sn\n".(pack "u", $_)."`\nend" if $_' /some/file/to_encode.gz
PHP The
PHP language has a native convert_uuencode() function: $ php -r "echo convert_uuencode('Cat');" • 0V%T ` Decoding is done with the corresponding convert_uudecode() function: $ php -r "echo convert_uudecode('#0V%T');" Cat == See also ==