Open woctezuma opened 1 year ago
There is no error if I run:
steamctl apps list
I can even get the ∞
character to be rendered correctly:
208570 Dishonored: Dunwall City Trials DLC
208575 Dishonored: The Knife of Dunwall
208580 STAR WARS™ Knights of the Old Republic™ II: The Sith Lords™
208610 Skullgirls ∞Endless Beta∞
208620 Midnight Mysteries: Salem Witch Trials
208630 Midnight Mysteries 3: Devil on the Mississippi
208640 Midnight Mysteries 4: Haunted Houdini
However, the list is really long, so it gets truncated by the Windows console, and it would be handier to save it to a text file.
I remember encountering this issue in the past, without reporting it, and then editing the code to save the output to a file. I wonder if there is a better fix.
On a side-note, I am not sure if the issue only happens on Windows.
The error can be reproduced with a Python file scratch_1.py
, unrelated to steamctl
:
print('∞')
python scratch_1.py
Output:
∞
python scratch_1.py > temp.txt
Output:
Traceback (most recent call last):
File "C:\Users\Wok\AppData\Roaming\JetBrains\PyCharmCE2022.2\scratches\scratch_1.py", line 1, in <module>
print('∞')
File "C:\Users\Wok\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u221e' in position 0: character maps to <undefined>
Use a terminal that supports utf8 and is configured to use utf8
Use a terminal that supports utf8 and is configured to use utf8
That is the case. The issue is with the redirection to a file, which does not seem to work properly on Windows.
For instance, in the picture below, there is no error, but an inconsistency.
echo ∞
echo ∞ > temp.txt
type temp.txt
I can fix the inconsistency with chcp 65001
, but that does not fix the error when redirecting the output of a Python script.
chcp 65001
echo ∞
echo ∞ > temp.txt
type temp.txt
For the error with Python, I have a small workaround.
Description I want to export the list of apps to a text file using the Windows console, and there is an
UnicodeEncodeError
error.Steps to Reproduce the behavior
Run:
steamctl apps list > apps_list.txt
Expected behavior The software should run without any error, and the text file should contain the lists of appIDs along the app names.
What actually happend
The error happens for appID=208610 which is
Skullgirls ∞Endless Beta∞
. I believe the culprit is the∞
character.Logs
steamctl -l debug
``` [DEBUG] steamctl: Parsed args: {'versions_report': None, 'log_level': 'debug', 'anonymous': False, 'user': None, 'password': None, 'command': 'apps', '_cmd_func': 'steamctl.commands.apps.gcmds:cmd_apps_list', 'subcommand': 'list', 'all': False} [DEBUG] SteamClient: Reading CM servers from 'C:\\Users\\Wok\\AppData\\Local\\steamctl\\steamctl\\client\\cm_servers.json' [DEBUG] CMServerList: Added 80 new CM addresses. [DEBUG] steamctl.utils.storage: Opening file (r): C:\Users\Wok\AppData\Local\steamctl\steamctl\client\lastuser [INFO] SteamClient: Reusing previous username: XXX [INFO] SteamClient: Hint: use 'steamctl --userVersions Report
steamctl --versions-report
```yaml steamctl: 0.9.5 Dependencies: steam: 1.4.3 appdirs: 1.4.4 argcomplete: 2.0.0 tqdm: 4.64.1 arrow: 1.2.3 pyqrcode: 1.2.1 beautifulsoup4: 4.11.1 vpk: 1.4.0 vdf: 3.4 gevent-eventemitter: 2.1 gevent: 22.10.2 greenlet: 2.0.1 pyyaml: Not Installed pycryptodomex: 3.15.0 protobuf: 3.20.3 Python runtime: executable: C:\Users\Wok\.local\pipx\venvs\steamctl\Scripts\python.exe version: 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] platform: win32 System info: system: Windows machine: AMD64 release: 10 version: 10.0.19044 ```