Everybody know encodings. Wether it’s the plain old Base64 or the more ancient uuencodeing, when working in IT you just can’t avoid them.

Encoding is used when the channel you want to transport data over only permits a certain set of codepoints. For example, if you need to - for whatever reason - transport data over a radio teletype, which only has uppercase character and numerals, you’d use Base32:

$ echo 'I 💚 Encodings' | base32 
JEQPBH4STIQEK3TDN5SGS3THOMFA====

But what would you do, if for whatever reason, you’re stuck with only numerals, not even hexadecimal? I had to tackle such a problem today, where the transport channel in question is a phone call, and data must be transported as DTMF tones.

‘Lo and behold, arbitrary DTMF-encoding:

import binascii
In [477]: int(binascii.hexlify(bytearray('I 💚 Encodings', 'utf-8')), 16)
Out[477]: 97204677612725827781666465682048313203

In [478]: binascii.unhexlify(hex(97204677612725827781666465682048313203).lstrip('0x')).decode('utf-8')
Out[478]: 'I 💚 Encodings'

Note: The use of *, # and the use of the special DTMF-tones A-D make it a full hexadecimal system, but A-D is not guaranteed to be transported as their historical use was for network control and are still often filtered in PSTNs or PLMNs.