I can find the uuencode character mappings on wikipedia. Does python have a means to loop through this list?
for x in [builtin_uuencode_mappings]:
print(x)
I would like to focus on special characters such as "!@#$" and so on.
I can find the uuencode character mappings on wikipedia. Does python have a means to loop through this list?
for x in [builtin_uuencode_mappings]:
print(x)
I would like to focus on special characters such as "!@#$" and so on.
Copyright © 2021 Jogjafile Inc.
Python already has built-in support for encoding and decoding uuencoded messages.
Internally python uses the
binasciipackage to encode or decode the message line by line. We can use that to encode a single byte or even all bytes in therange(64)(because uuencoding tranforms 6bit into an ascii character:2**6 == 64).To generate all necessary bit patterns we can count to 64 and shift the result by 2 bit to the left. That way the highest 6 bits count from 0 to 64. Then it's just a matter of converting that into python
bytes, uuencode them and extract the actual character.In python2
In python3 the first part is a little bit ugly.
Thanks to Mark Ransom who explained why the bit shifting actually works.