Skip to content

Problem with sending emails with emojis #114

Closed
@spoof

Description

@spoof

I got an issue with emails that contain emojis. When I receive email with emojis
all emojies are displayed like a bunch of '??'. I tried to send the same data via Postman
and email I received wasn't broken. So it seems someting wrong happens on the way
between this python client and API server.
By digging into source code of Transmissions part and by sniffing traffic
I found that python's json module encodes (dumps) 'not simple' non-ascii characters
(such emojies) to '\uXXXX' notation as a surrogate pair (as expected):

>>> emoji = u"😄"
>>> emoji
u'\U0001f604'
>>> print json.dumps(emoji)
"\ud83d\ude04"

By sending this data I got this emoji looks like:

\xed\xa0\xbd\xed\xb8\x84

And it's of course wrong. I sniffed traffic between Postman and API server and I found
that Postman sends json in utf-8 (without escaping to \uXXXX):

\xf0\x9f\x98\x84

So I repeat this in Python and it worked:

>>> json.dumps(emoji, ensure_ascii=False).encode('utf-8')
'"\xf0\x9f\x98\x84"'

I don't know on what side problem is, but this is my workaround to handle this problem.
And this Issue is just a point on a problem and its possible solution.

PS. There is no problem with sending emails consist of simple chars like '\u2605'.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions