Convert hex to char

main
Bob Mottram 2020-02-21 16:58:33 +00:00
parent 075489bea4
commit 2b6aa3f44b
2 changed files with 3 additions and 2 deletions

View File

@ -65,7 +65,7 @@ def replaceEmojiFromTags(content: str,tag: [],messageType: str) -> str:
if iconName.startswith('1'):
if '.' in iconName:
iconName=iconName.split('.')[0]
content=content.replace(tagItem['name'],'\\u'+iconName)
content=content.replace(tagItem['name'],chr(int("0x"+iconName,16)))
htmlClass='emoji'
if messageType=='post header':
htmlClass='emojiheader'

View File

@ -1391,7 +1391,8 @@ def testAddEmoji():
tags.append(tag)
content=contentModified
contentModified=replaceEmojiFromTags(content,tags,'content')
assert contentModified=='<p>Emoji \\u1F34B \\u1F353 \\u1F34C</p>'
#print('contentModified: '+contentModified)
assert contentModified=='<p>Emoji 🍋 🍓 🍌</p>'
os.chdir(baseDirOriginal)
shutil.rmtree(baseDirOriginal+'/.tests')