Skip to content

Instantly share code, notes, and snippets.

@ff6347
Created October 8, 2012 15:53
Show Gist options
  • Save ff6347/3853231 to your computer and use it in GitHub Desktop.
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
# -*- 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