derrod / legendary

Legendary - A free and open-source replacement for the Epic Games Launcher
https://legendary.gl/discord
GNU General Public License v3.0
4.65k stars 165 forks source link

UnicodeEncodeError when verifying Cities: Skylines files #297

Closed AutumnRivers closed 3 years ago

AutumnRivers commented 3 years ago

Platform

Operating system and version: Windows 10 Home, v2004 Legendary version (legendary -V): legendary version "0.20.6", codename "A Red Letter Day"

Expected Behavior

The verification should either finish with no errors, or inform me what files are corrupted / missing

Current Behavior

At the end of verification, the process is interrupted with the following error:

Traceback (most recent call last):
  File "legendary\cli.py", line 1375, in <module>
  File "legendary\cli.py", line 1355, in main
  File "legendary\cli.py", line 835, in verify_game
UnicodeEncodeError: 'cp932' codec can't encode character '\u2013' in position 46097: illegal multibyte sequence
[17020] Failed to execute script cli

This happens on both CMD and Powershell.

Steps to Reproduce

  1. Run legendary verify-game bcbc03d8812a44c18f41cf7d5f849265 (if you have Cities: Skylines installed)
  2. Wait for verification to finish

Additional information

I'm not sure if this happens with any other games. As far as I know, it doesn't.

CommandMC commented 3 years ago

Seems like this is some sort of locale issue.

If you have Python installed, could you run py -c 'import locale; print(locale.getpreferredencoding())' and check if that's also saying cp932?

Also, sidenote: Update your Windows version. 2004 is over a year old at this point.

derrod commented 3 years ago

Seems like your Windows is set to Japanese, which uses a limited codepage that doesn't support the "en dash" character (–) and based on the line it fails on that character is used in a filename of the game, and trying to write that to a file with the default encoding just fails.

This is fixable, the line above just needs to explicitly set the file encoding to utf-8 or something more compatible like it. Might be a good idea to check the program in general for this kind of issue and make all encodings explicit to avoid Windows unicode issues...

derrod commented 3 years ago

This is a reminder to me to fix this for 0.20.11.