Answer the question
In order to leave comments, you need to log in
How to send sms using unicode via api gateway?
In general, I chose a site to send SMS on behalf of my company. But by default, there is no way to send SMS in Russian. I wrote to support, here's what they told me. But I can't figure out what the code should look like. Can someone show an example? With filled lines for example. Help me please. I am attaching the default code and the answer to my appeal to the question. Thanks for answers.
Answer the question
In order to leave comments, you need to log in
In principle, technical support gave you a ready-made code.
It is necessary to encode the SMS body itself in UCS-2.
UCS-2 is a character encoding standard in which characters are represented by 16 fixed length bits (2 bytes). It is used as a fallback in many GSM networks when the message cannot be encoded with GSM-7 or when the language requires more than 128 characters to display (eg UTF-8).
View Unicode UCS-2 Code Chart
from binascii import hexlify
url = "..."
querystring = {..., ...,}
headers = {...}
content = querystring['content'].encode('utf-16-be')
querystring['content'] = hexlify(content).decode('utf-8')
responce = request.....
from binascii import hexlify
querystring = {'content': 'Привет'}
content = querystring['content'].encode('utf-16-be')
querystring['content'] = hexlify(content).decode('utf-8')
print(querystring)
In [4]:
{'content': '041f04400438043204350442'}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question