Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError: 'charmap' codec can't encode character '\u202f' in position 54: character maps to <undefined> encoding with 'cp437' codec failed #184

Open
codejoey opened this issue Mar 1, 2024 · 5 comments

Comments

@codejoey
Copy link

codejoey commented Mar 1, 2024

Tried to view an export zip via Mac terminal.

Ran into this error which halts it. Any ideas?

Traceback (most recent call last):
File "/Users/Joey/.local/bin/slack-export-viewer", line 10, in
sys.exit(main())
^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/slackviewer/main.py", line 79, in main
configure_app(app, archive, channels, no_sidebar, no_external_references, debug)
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/slackviewer/main.py", line 21, in configure_app
path = extract_archive(archive)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/slackviewer/archive.py", line 74, in extract_archive
info.filename = info.filename.encode("cp437").decode("utf-8")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/encodings/cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u202f' in position 54: character maps to
encoding with 'cp437' codec failed

@gunchev
Copy link
Contributor

gunchev commented Apr 10, 2024

I managed to get something working by first extracting the archive in a new directory and then point the viewer to that. I know, workaround, but haven't debugged it. It was trying to decore an utf-8 string using cp437.

@BLiu1
Copy link

BLiu1 commented Jul 13, 2024

I ran into the same error. Did you happen to export from slackdump? It might be that slackdump is using UTF-8 instead of cp437 for the zip file.

@aalkz
Copy link
Contributor

aalkz commented Aug 9, 2024

I had this problem too, it was complaining about files with áéíóú characters in them. My temporay solution was to comment this line and suddenly it worked fine:

# info.filename = info.filename.encode("cp437").decode("utf-8")

info.filename = info.filename.encode("cp437").decode("utf-8")

I don't know why that encoding conversion is there in the first place though, I feel that it shouldn't be necessary and it creates problems for people that don't have English as their default language. 🤔

@jiangyi1985
Copy link

same problem

@conjon42
Copy link

conjon42 commented Oct 5, 2024

Same problem, using an archive from slackdump on MacOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants