Last active
May 5, 2018 11:22
-
-
Save fieldingtron/b7d9d02e11293b3d1be6745c49c35745 to your computer and use it in GitHub Desktop.
replace wierd wordpress characters in utf-8 in markdown files using python 3
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 python | |
filename = "filemarkdown.md" | |
## OPEN FILE READ TO FILEDATA | |
f = open(filename,'r', encoding="utf-8") | |
newdata = f.read() | |
f.close() | |
#REPLACE wierd characters | |
newdata = newdata.replace( '‘', '‘') | |
newdata = newdata.replace( '’', '’') | |
newdata = newdata.replace( '‘', '‘') | |
newdata = newdata.replace( '—', '–') | |
newdata = newdata.replace( '–', '—') | |
newdata = newdata.replace( '•', '-') | |
newdata = newdata.replace( '…', '…') | |
newdata = newdata.replace('â€', '”') | |
newdata = newdata.replace( '�', '') | |
newdata = newdata.replace( '', '') | |
#rewrite the files | |
f = open(filename,'w', encoding="utf-8") | |
f.write(newdata) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment