Created
March 12, 2012 08:52
-
-
Save asus4/2020785 to your computer and use it in GitHub Desktop.
Export unique char from unicode text file. for Unity
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
#!/usr/bin/python | |
# coding: utf-8 | |
import codecs,sys | |
""" | |
convert text to uniq characters | |
for Unity | |
ex: | |
python uniq_char.py in.txt out_uniq.txt | |
""" | |
argvs = sys.argv | |
argc = len(argvs) | |
# check argvs | |
if (argc != 3): | |
print 'Usage: # python %s in_file out_file' % argvs[0] | |
quit() | |
# open file | |
f = codecs.open(argvs[1], 'r', 'utf8') | |
txt = f.read() | |
f.close() | |
# sort | |
txt = sorted(set(txt), key=txt.index) | |
out = u"" | |
for t in txt: | |
out += t | |
print "-------sorted-------" | |
print out | |
# write to file | |
fout = codecs.open(argvs[2], 'w', 'utf8') | |
fout.write(out) | |
fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
README
日本語フォントをGlyphDesignerなどから作成するときに、使う文章から文字の重複を削除し、
指定の文章内から使っている文字のみを書きだすスクリプトです。