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

Directory export crashes in Windows with certain characters - UnicodeEncodeError: 'locale' codec can't encode character #1089

Closed
micahellison opened this issue Nov 21, 2020 · 0 comments · Fixed by #1090
Assignees
Labels
bug Something isn't working windows

Comments

@micahellison
Copy link
Member

Bug Report

Environment

  • Jrnl --diagnostic output:
jrnl: v2.5
Python: 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)]
OS: Windows 10
  • Install method: pipx

Current Behavior

I was trying to reproduce the bug in #580 but hit an error message on the step where I'm exporting to a directory: UnicodeEncodeError: 'locale' codec can't encode character '\u043f' in position 9: encoding error

It seems so far that only certain Cyrillic characters are leading to this bug. Other non-English characters such as é seem to be fine, as does emoji characters.

Expected Behavior

jrnl should export the jrnl's contents without errors.

Repro Steps

  • Start with an empty default jrnl
  • Run the following in the Windows Terminal or the traditional Command Prompt: (confirmed in both)
jrnl Первая
mkdir .\jrnltest
jrnl --export md -o .\jrnltest

Other Information

Here's the traceback, which is the only output I get:

Traceback (most recent call last):
  File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\micah\.local\bin\jrnl.exe\__main__.py", line 7, in <module>
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\cli.py", line 47, in cli
    return run(args)
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\jrnl.py", line 61, in run
    search_mode(**kwargs)
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\jrnl.py", line 157, in search_mode
    _display_search_results(**kwargs)
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\jrnl.py", line 302, in _display_search_results
    print(exporter.export(journal, args.filename))
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\plugins\text_exporter.py", line 73, in export
    return cls.write_files(journal, output)
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\plugins\text_exporter.py", line 49, in write_files
    full_path = os.path.join(path, cls.make_filename(entry))
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\plugins\text_exporter.py", line 41, in make_filename
    "%Y-%m-%d_{}.{}".format(cls._slugify(str(entry.title)), cls.extension)
UnicodeEncodeError: 'locale' codec can't encode character '\u043f' in position 9: encoding error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows
Projects
None yet
1 participant