Created
June 27, 2018 16:54
-
-
Save jonathanrobie/cea26d9318a7b8b0413103329479807a to your computer and use it in GitHub Desktop.
Convert files to Unicode (NFKC)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import unicodedata | |
import fnmatch | |
import sys | |
import os | |
for file in os.listdir('.'): | |
for arg in sys.argv: | |
if fnmatch.fnmatch(file, arg): | |
inf = file + '.bak' | |
os.rename(file, inf) | |
with open(inf) as inf: | |
with open(file,'w+') as outf: | |
for line in inf: | |
outf.write(unicodedata.normalize("NFKC", line)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Converts all files in the current directory to Unicode, using NFKC normalization. Creates .bak files just in case.