From 8b2809779f94caee24b5ddc0464e744bf776527e Mon Sep 17 00:00:00 2001 From: derrod Date: Sun, 28 May 2023 00:16:21 +0200 Subject: [PATCH] [cli] Set non-tty output encoding to UTF-8 Closes #551 and #554 --- legendary/cli.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/legendary/cli.py b/legendary/cli.py index 7cf321a..6a7bca9 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -2539,6 +2539,10 @@ class LegendaryCLI: def main(): + # Set output encoding to UTF-8 if not outputting to a terminal + if not stdout.isatty(): + stdout.reconfigure(encoding='utf-8') + parser = argparse.ArgumentParser(description=f'Legendary v{__version__} - "{__codename__}"') parser.register('action', 'parsers', HiddenAliasSubparsersAction)