Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AAriam committed Jan 26, 2024
1 parent f2fdd9d commit 5b074a9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/actionman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
from actionman import io, log, pprint, shell


_sys.stdout = _io.TextIOWrapper(_sys.stdout.buffer, encoding='utf-8')
if hasattr(_sys.stdout, 'buffer'):
# Wrap the standard output stream to change its encoding to UTF-8,
# which is required for writing unicode characters (e.g., emojis) to the console in Windows.
# However, this works in standard Python environments where sys.stdout is a regular file object;
# in environments like Jupyter, sys.stdout is already set up to handle Unicode,
# and does not need to be (and cannot be) wrapped in this way.
_sys.stdout = _io.TextIOWrapper(_sys.stdout.buffer, encoding='utf-8')

0 comments on commit 5b074a9

Please sign in to comment.