Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Uuencoding
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Support in languages == === Python === The [[Python (programming language)|Python]] language supports uuencoding using the codecs module with the codec "uu": For Python 2 ''(deprecated/sunset as of January 1st 2020)'': <syntaxhighlight lang="console" highlight="3"> $ python -c 'print "Cat".encode("uu")' begin 666 <data> #0V%T end $</syntaxhighlight> For Python 3 ''where the codecs module needs to be imported and used directly'': <syntaxhighlight lang="console" highlight="2"> $ python3 -c "from codecs import encode;print(encode(b'Cat', 'uu'))" b'begin 666 <data>\n#0V%T\n \nend\n' $</syntaxhighlight> To decode, pass the whole file: <syntaxhighlight lang="console" highlight="2"> $ python3 -c "from codecs import decode;print(decode(b'begin 666 <data>\n#0V%T\n \nend\n', 'uu'))" b'Cat' </syntaxhighlight> === Perl === The [[Perl]] language supports uuencoding natively using the pack() and unpack() operators with the format string "u": <syntaxhighlight lang="console"> $ perl -e 'print pack("u","Cat")' #0V%T </syntaxhighlight> Decoding base64 with unpack can likewise be accomplished by translating the characters: <syntaxhighlight lang="console"> $ perl -e 'print unpack("u","#0V%T")' Cat </syntaxhighlight> To produce wellformed uuencoded files, you need to use modules,<ref>{{Cite web |title=PerlPowerTools source |url=https://metacpan.org/dist/PerlPowerTools |access-date=2024-02-12 |website=metacpan.org |language=en-US}}</ref> or a little bit more of code:<ref>{{Cite web |title=uuencode.pl source |url=http://main.linuxfocus.org/~guido/scripts/uuencode_pl.html |access-date=2024-02-12 |website=main.linuxfocus.org |language=en-US}}</ref> ==== Encode (oneliner) ==== <syntaxhighlight lang="console"> $ perl -ple 'BEGIN{use File::Basename;$/=undef;$sn=basename($ARGV[0]);} $_= "begin 600 $sn\n".(pack "u", $_)."`\nend" if $_' /some/file/to_encode.gz </syntaxhighlight> ==== Encode/Decode (proper Perl scripts) ==== https://metacpan.org/dist/PerlPowerTools/view/bin/uuencode https://metacpan.org/dist/PerlPowerTools/view/bin/uudecode
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)