Skip to content

Instantly share code, notes, and snippets.

@tcalmant
Created September 27, 2022 13:23
Show Gist options
  • Save tcalmant/0b68e1343e5774f12bec0bd89933f082 to your computer and use it in GitHub Desktop.
Save tcalmant/0b68e1343e5774f12bec0bd89933f082 to your computer and use it in GitHub Desktop.
Converts UTF-8 Java properties files into ISO-8859-1 with \u encoding
import pathlib
for p in pathlib.Path(".").glob("*.properties"):
with open(p, "r", encoding="utf-8") as fd:
converted = fd.read().encode("raw-unicode-escape").decode("latin1")
with open(p, "w", newline="\n", encoding="latin1") as fd:
fd.write(converted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment