diff --git a/ntfy_lite/ntfy.py b/ntfy_lite/ntfy.py index e47835d..098b4a7 100644 --- a/ntfy_lite/ntfy.py +++ b/ntfy_lite/ntfy.py @@ -52,8 +52,7 @@ def __init__( if filepath is not None: self._data = open(filepath, "rb") elif message is not None: - self._data = message.encode(encoding="UTF-8", errors="replace").decode() - self._data = message.encode(encoding="latin-1", errors="replace").decode() + self._data = message.encode(encoding="latin-1", errors="replace").decode(encoding="latin-1") def __enter__(self) -> typing.Union[typing.IO, str]: return self._data diff --git a/tests/test_ntfy_lite.py b/tests/test_ntfy_lite.py index d7ccbce..9bc4d83 100644 --- a/tests/test_ntfy_lite.py +++ b/tests/test_ntfy_lite.py @@ -135,6 +135,20 @@ def test_action_http_push(clear): ntfy.push(topic, title, message=message, actions=action, dry_run=True) +def test_extended_ascii_push(): + topic = "ntfy_lite_test" + title = "ntfy lite test extended ascii push" + message = "ntfy_extended_ascii_push message: (°_°)" + ntfy.push(topic, title, message=message, dry_run=True) + + +def test_unicode_push(): + topic = "ntfy_lite_test" + title = "ntfy lite test unicode push" + message = "ntfy unicode push message: 🐋💐🪂" + ntfy.push(topic, title, message=message, dry_run=True) + + @pytest.mark.parametrize("clear", [True, False]) def test_actions_view_http_push(clear): topic = "ntfy_lite_test"