Encoding Bangla (Unicode) SMS for SSLWireless in Python
If you are wondering why you cannot send Bengali text encoded in Unicode properly through the SSLWireless Push API in Python, well you are not alone. The solution is, encoding your UTF-8 text into UTF-16 (Big Endian) and then taking the hexadecimal value of it, transformed into uppercase.
def encode(message):
return message.encode('utf-16-be').hex().upper()
Let's witness this step by step.
>>> message = 'আমার সোনার বাংলা'
>>> message
'আমার সোনার বাংলা'
>>> message.encode('utf-16-be')
b'\t\x86\t\xae\t\xbe\t\xb0\x00 \t\xb8\t\xcb\t\xa8\t\xbe\t\xb0\x00 \t\xac\t\xbe\t\x82\t\xb2\t\xbe'
>>> message.encode('utf-16-be').hex()
'098609ae09be09b0002009b809cb09a809be09b0002009ac09be098209b209be'
>>> message.encode('utf-16-be').hex().upper()
'098609AE09BE09B0002009B809CB09A809BE09B0002009AC09BE098209B209BE'
And that is how it is done. Hope it helped! N.B. The rest of the details about how to perform a request, are in the documentation you have received from SSLWireless.