From 20441ebc6bce4c105fffa267bd086286db79768e Mon Sep 17 00:00:00 2001 From: Wok Date: Sun, 20 Nov 2022 16:29:39 +0100 Subject: [PATCH] Fix UnicodeEncodeError when redirecting the output on Windows Reference: https://stackoverflow.com/a/74509356/376454 --- steamctl/commands/apps/gcmds.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/steamctl/commands/apps/gcmds.py b/steamctl/commands/apps/gcmds.py index 36cf4df..ab03d85 100644 --- a/steamctl/commands/apps/gcmds.py +++ b/steamctl/commands/apps/gcmds.py @@ -94,7 +94,12 @@ def cmd_apps_list(args): cdn.load_licenses() for app_id in sorted(cdn.licensed_app_ids): - print(app_id, app_names.get(app_id, 'Unknown App {}'.format(app_id))) + app_name = app_names.get(app_id, 'Unknown App {}'.format(app_id)) + try: + print(f"{app_id} {app_name}") + except UnicodeEncodeError: + app_name = app_name.encode("ascii", errors="replace").decode("ascii") + print(f"{app_id} {app_name}") def cmd_apps_item_def(args):