Closed BigDi closed 2 months ago
super quick fix, i hope somebody sees it lol @ephes @alexdetsch @luebbert42
in repository.py add utf8 encodings in the functions:
you can do it in your local code @BigDi
Well, pydantic deliberately returns a unicode string when models.model_dump_json()
is called. And calling write on a file opened in text mode should do the right thing on your operating system. Maybe your default encoding is something like cp1252
?
Hmm, maybe it's enough just to overwrite the operating system default by calling:
with self.path.open("w", encoding="utf-8") as f:
f.write(models.model_dump_json())
This is still normal text mode, but would overwrite the default encoding and use utf-8. Can you try this and tell me if it works on windows?
I can confirm that the additional encoding solves the problem on windows.
Cool! I'll released 0.0.21 containing the fix.
Get a traceback while backuping my 1086 favorites.
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ C:\Python311\Lib\site-packages\kptncook__init__.py:167 in backup_kptncook_favorites │ │ │ │ 164 │ │ sys.exit(1) │ │ 165 │ │ │ 166 │ fs_repo = RecipeRepository(settings.root) │ │ ❱ 167 │ fs_repo.add_list(recipes) │ │ 168 │ rprint(f"Added {len(recipes)} recipes to local repository") │ │ 169 │ │ 170 │ │
UnicodeEncodeError: 'charmap' codec can't encode character '\u202f' in position 829203: character maps to