django - python convert emoji to HTML decimal -


i have django application consumes twitter public api.

the tweets application received contains emojis , want convert html decimal equivalent.

searching python emoji found 2 libraries (emoji_unicode, pyemoji).

i using 2 libraries following decimal value of emoji included in tweet body;

import emoji_unicode, pyemoji def emoji_callback(e):     t = pyemoji.encode(e.unicode).replace('\\u','')     return "&#%s;" % str(int(t, 16)) emoji_unicode.replace(u'time ⛽ ',emoji_callback) 

the previous example works fine other emojis did not work , throws invalid literal int() base 16 exception. example below code not work.

emoji_unicode.replace(u'time 🌄',call) 

questions

1- there simpler way html decimal of emoji in tweet body instead of implemented here?

2- if no, how solve exception , code working emojis?

something :)

def emoji_calback(e):     '&#x{0};'.format(e.unicode.encode('unicode_escape').decode('utf8').lstrip('\\u0u')) 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -