Created
December 16, 2015 01:08
-
-
Save taoy/d7f1c4d61d5659066c6a to your computer and use it in GitHub Desktop.
Python (2.7) Normalize Japanese Text File. (Hankaku, Zenkaku)
This file contains hidden or 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
import unicodedata | |
filename = 'somefilename.txt' | |
f = open(file, 'r') | |
r = f.read() | |
f.close() | |
ur = r.decode('utf-8') | |
n = unicodedata.normalize('NFKC', ur) | |
outfile = 'outfile.txt' | |
f = open(outfile, 'wb') | |
f.write(n.encode('utf-8')) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment