Add handling for no stdout encoding to text drawer (#5762)
Add handling for no stdout encoding to text drawer (#5762)

There are times when the sys.stdout encoding may be None. Namely if the
sys.stdout object is replaced with a buffer like io.StringIO. This is a
common pattern in testing and is also how the stdlib unittest's --buffer
flag works. However, by default io.StringIO the encoding attribute is
set to None. In this case the text drawer attempts to explicitly encode
a string to bytes with a None encoding which will result in an error. To
address this case this commit adds handling for when sys.stdout.encoding
is None and in those cases it sets a fallback default to utf8 which is
the default character encoding for python3 strings.

Co-authored-by: Kevin Krsulich <78cdb98aeddd45630046ff39f0a19d75c82aaaa7@ibm.com>
Co-authored-by: mergify[bot] <b09a6ee808b67e98a221404e7aaa52e0398a4954@users.noreply.github.com>
QISKit/qiskit-sdk-py,QISKit/qiskit-sdk-py,QISKit/qiskit-sdk-py