diff --git a/pyproject.toml b/pyproject.toml
index b62cead..98d7ec6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
 
 [project]
 name = "dmenu_extended"
-version = "1.2.3"
+version = "1.2.4"
 authors = [
   { name="Mark Hedley Jones", email="markhedleyjones@gmail.com" },
 ]
diff --git a/src/dmenu_extended/main.py b/src/dmenu_extended/main.py
index 96374f4..45b53a4 100755
--- a/src/dmenu_extended/main.py
+++ b/src/dmenu_extended/main.py
@@ -786,11 +786,14 @@ def cache_save(self, items, path):
             for item in items:
                 clean = True
                 for char in item:
-                    if char not in string.printable:
+                    if not str.isprintable(char):
                         clean = False
                         foundError = True
                         if self.debug:
-                            print("Culprit: " + item)
+                            print(
+                                "Culprit: "
+                                + item.encode("unicode_escape").decode("utf-8")
+                            )
                 if clean:
                     tmp.append(item)
             if foundError:
@@ -802,7 +805,7 @@ def cache_save(self, items, path):
                     print("Offending items have been excluded from cache")
                 with open(path, "wb") as f:
                     for item in tmp:
-                        f.write(item + "\n")
+                        f.write(item.encode("unicode_escape") + b"\n")
                 return 2
             else:
                 if self.debug: