decode 7-bit GSM

johannes picture johannes · Oct 30, 2012 · Viewed 13.1k times · Source

I found this post on how to encode ascii data to 7-bit GSM character set, how would I decode 7-bit GSM character again (reverse it back to ascii)?

Answer

noiam picture noiam · Jun 16, 2015

For example:

C7F7FBCC2E03 stands for 'Google'
Python 3.4

def gsm7bitdecode(f):
   f = ''.join(["{0:08b}".format(int(f[i:i+2], 16)) for i in range(0, len(f), 2)][::-1])
   return ''.join([chr(int(f[::-1][i:i+7][::-1], 2)) for i in range(0, len(f), 7)])

print(gsm7bitdecode('C7F7FBCC2E03'))

Google