Mercurial > repos > davidvanzessen > argalaxy_tools
diff convert_windows_to_utf-8.py @ 58:4c6df851e262 draft default tip
"planemo upload commit 1a7731bb4fe2e80fb1fdc88121783068af3edb08"
author | rhpvorderman |
---|---|
date | Fri, 21 Apr 2023 10:04:39 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/convert_windows_to_utf-8.py Fri Apr 21 10:04:39 2023 +0000 @@ -0,0 +1,14 @@ +import argparse + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("files", nargs="+") + args = parser.parse_args() + for file in args.files: + with open(file, "rb") as in_r: + data = in_r.read() + text = data.decode("windows-1252") + text = text.replace("charset=windows-1252", "charset=\"UTF-8\"", 1) + with open(file, "wt", encoding="UTF-8") as out: + out.write(text) +