bsolomon1124 / demoji

Accurately find/replace/remove emojis in text strings
https://pypi.org/project/demoji/
Apache License 2.0
157 stars 20 forks source link

Fix colors in Windows console #5

Closed alexgoryushkin closed 4 years ago

alexgoryushkin commented 4 years ago

Windows cmd not support escape sequences by default. But it can be fixed:

import sys
import demoji

if ('win' in sys.platform):
    import ctypes
    kernel32 = ctypes.windll.kernel32
    kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)

demoji.download_codes()

Output before: image

Output after: image

bsolomon1124 commented 4 years ago

Thanks for bringing this up - I'm going to add https://pypi.org/project/colorama/ which addresses this specifically. (Cool ctypes trick though 😄 )

bsolomon1124 commented 4 years ago

Please let me know if upgrading demoji does not solve this issue for you @alexgoryushkin . Thanks!