Discussion:
python-gammu - how do I encode/decode an SMS which contains emoji?
tradegeek+
2017-02-09 00:08:11 UTC
Permalink
Hi,

I'm unable to successfully encode/decode an SMS containing emoji.

Using Python 3 and the Python-Gammu library, I encode a PDU for message
text containing an emoji character 😂 (Unicode character U+1F602 -
"FACE WITH TEARS OF JOY"):

The PDU returned is "07918188558588f811000b912121551532f40018ff02f602".

When I then decode this PDU using the Python-Gammu library, the message
text contains an unrecognised character  (\xEF\x98\x82), rather than
the Unicode emoji character.

*** I get the same result using Wammu's own encoder and decoder tools at
https://wammu.eu/tools/pdu-encode/ and
https://wammu.eu/tools/pdu-decode/ . ***

I wonder whether this is something to do with the gammu library working
strictly to the GSM specification and interpreting the UDH payload as
UCS-2 encoded rather than as UTF-16. Nevertheless, emoji are now in
common use within SMS messages, and I need to find a way of converting
gammu's literal decoding back to the original emoji as entered by the
sending party.

Would anyone please be able to guide me on how to achieve this?

Thanks, David.
Michal ÄŒihaÅ™
2017-02-10 13:44:40 UTC
Permalink
Hi
Post by tradegeek+
Hi,
I'm unable to successfully encode/decode an SMS containing emoji.
Using Python 3 and the Python-Gammu library, I encode a PDU for
message 
text containing an emoji character 😂  (Unicode character U+1F602 - 
The PDU returned is
"07918188558588f811000b912121551532f40018ff02f602".
When I then decode this PDU using the Python-Gammu library, the
message 
text contains an unrecognised character  (\xEF\x98\x82), rather
than 
the Unicode emoji character.
*** I get the same result using Wammu's own encoder and decoder tools
at 
https://wammu.eu/tools/pdu-encode/  and 
https://wammu.eu/tools/pdu-decode/ . ***
I wonder whether this is something to do with the gammu library
working 
strictly to the GSM specification and interpreting the UDH payload
as 
UCS-2 encoded rather than as UTF-16. Nevertheless, emoji are now in 
common use within SMS messages, and I need to find a way of
converting 
gammu's literal decoding back to the original emoji as entered by
the 
sending party.
Would anyone please be able to guide me on how to achieve this?
This can be achieved by fixing bug in python-gammu :-). See our issue
tracker:

https://github.com/gammu/python-gammu/issues/16
--
Michal Čihař | https://cihar.com/ | https://weblate.org/
tradegeek+
2017-02-10 13:58:40 UTC
Permalink
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

Loading...