From b511461cfa8e0cbf5436e084ccef8a46028d4faa Mon Sep 17 00:00:00 2001 From: Micah Jerome Ellison Date: Sat, 21 Nov 2020 15:41:08 -0800 Subject: [PATCH] Fix Unicode encoding failure in directory export when creating filenames from journal titles with certain characters (#1090) Fix Unicode encoding failure in directory export when creating filenames from journal titles with certain characters --- features/format.feature | 18 ++++++++++++++++++ jrnl/plugins/text_exporter.py | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/features/format.feature b/features/format.feature index c471eac6..f5156301 100644 --- a/features/format.feature +++ b/features/format.feature @@ -536,3 +536,21 @@ Feature: Custom formats [2013-06-10 15:40] Life is good. But I'm better. """ + + Scenario Outline: Exporting entries with Cyrillic characters to directory should not fail + Given we use the config ".yaml" + And we use the password "test" if prompted + And we create a cache directory + When we run "jrnl 2020-11-21: Первая" + When we run "jrnl --format md --file {cache_dir} -on 2020-11-21" + Then the cache should contain the files + """ + 2020-11-21_первая.md + """ + + Examples: configs + | config | + | basic_onefile | + | basic_encrypted | + | basic_folder | + | basic_dayone | diff --git a/jrnl/plugins/text_exporter.py b/jrnl/plugins/text_exporter.py index 68061e4e..ebe50016 100644 --- a/jrnl/plugins/text_exporter.py +++ b/jrnl/plugins/text_exporter.py @@ -37,8 +37,8 @@ class TextExporter: @classmethod def make_filename(cls, entry): - return entry.date.strftime( - "%Y-%m-%d_{}.{}".format(cls._slugify(str(entry.title)), cls.extension) + return entry.date.strftime("%Y-%m-%d") + "_{}.{}".format( + cls._slugify(str(entry.title)), cls.extension ) @classmethod