Created
October 8, 2012 15:53
-
-
Save ff6347/3853231 to your computer and use it in GitHub Desktop.
Converting Characters from one textfile into Unicode Numbers saving them in another file
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
# -*- coding: utf-8 -*- | |
import unicodedata | |
gl = open('GlyphList.txt') | |
string = str(gl.read()) | |
string = unicode(string, 'utf-8') | |
gl.close() | |
glyphs = string.split() | |
try: | |
# This tries to open an existing file but creates a new file if necessary. | |
gl_unicode = open('GlyphsList-UniCode.txt', 'w') | |
except IOError: | |
pass | |
for glyph in glyphs: | |
# glyph = unicodedata.name(glyph) | |
glyph = '%04x' % ord(glyph) | |
gl_unicode.write(str(glyph) +'\n') | |
gl_unicode.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment