I am having trouble displaying Unicode characters on git-bash when working with Python's logging
.
logging
- everything works fine.cmd
- everything works fine.PyCharm
- everything works fine.logging
with git-bash
- not working (displaying "\u2501").See below...
I am using:
Well, as commented, logging
is using sys.stderr
and not sys.stdout
.
As for the terminals (at least on my Windows machine):
cmd
the default encoding for both sys.stdout
and sys.stderr
is utf-8
.git-bash
the default encoding for both sys.stdout
and sys.stderr
is cp1252
. Really no idea why. I would assume most git-bash
users want Linux-like behavior.It seems that both terminals accept utf-8
.
Since my script only needs to be run on these two terminals, the following solves my problem:
import sys
sys.stderr.reconfigure(encoding='utf-8')