From 94dc64decef9a62de408f722b4b7cf2a3b6e6ec2 Mon Sep 17 00:00:00 2001
From: Dominik George <nik@naturalnet.de>
Date: Tue, 14 Jan 2020 23:02:32 +0100
Subject: [PATCH] Use system default encoding when normalising locale

---
 calendarweek/util.py | 6 ++++--
 pyproject.toml       | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/calendarweek/util.py b/calendarweek/util.py
index 3d8c10e..676d6b0 100644
--- a/calendarweek/util.py
+++ b/calendarweek/util.py
@@ -1,4 +1,4 @@
-from locale import locale_alias, locale_encoding_alias
+from locale import getpreferredencoding, locale_alias, locale_encoding_alias
 from typing import Optional
 
 
@@ -6,5 +6,7 @@ def normalise_locale(loc: str, enc: Optional[str] = None) -> str:
     loc = locale_alias.get(loc, loc)
     if enc:
         enc = locale_encoding_alias.get(enc.replace("-", ""), enc)
-        loc = loc.split(".")[0] + "." + enc
+    else:
+        enc = getpreferredencoding()
+    loc = loc.split(".")[0] + "." + enc
     return loc
diff --git a/pyproject.toml b/pyproject.toml
index f43ff27..d1fe0e2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "calendarweek"
-version = "0.4.0"
+version = "0.4.1"
 description = "Utilities for working with calendar weeks in Python and Django"
 authors = ["Dominik George <nik@naturalnet.de>", "Jonathan Weth <git@jonathanweth.de>"]
 license = "MIT"
-- 
GitLab