gsm = (
    '@\xa3$\xa5\xe8\xe9\xf9\xec\xf2\xc7\n\xd8\xf8\r\xc5\xe5\u0394_\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\x1b\xc6\xe6\xdf\xc9 !"#\xa4%&\'()*+,-./0123456789:;<=>?\xa1ABCDEFGHIJKLMNOPQRSTUVWXYZ\xc4\xd6\xd1\xdc\xa7\xbfabcdefghijklmnopqrstuvwxyz\xe4\xf6\xf1\xfc\xe0'
    )
ext = (
    '````````````````````^```````````````````{}`````\\````````````[~]`|````````````````````````````````````\u20ac``````````````````````````'
    )

def gsm_encode(plaintext):
    res = ''
for c in plaintext:
    idx = gsm.find(c)
if idx != -1:
    res += chr(idx)
continue
idx = ext.find(c)
if idx != -1:
    res += chr(27) + chr(idx)
return res.encode('hex')
print(gsm_encode('Hello World'))
Библиотека Python для преобразования простого текста (ASCII) в 7-битный набор символов GSM?