Skip to content

Instantly share code, notes, and snippets.

@zhangw
Created August 28, 2014 11:02
Show Gist options
  • Select an option

  • Save zhangw/1dc231c1f853556debdd to your computer and use it in GitHub Desktop.

Select an option

Save zhangw/1dc231c1f853556debdd to your computer and use it in GitHub Desktop.
convert unicode one-character to integer,return unicode one-character with ordinal integer.
#unicode character
char = u'\u2708'
print char
#integer value of the character
ord_char = ord(char)
print ord_char,hex(ord_char)
#return the character
uni_char = unichr(ord_char)
assert(char==uni_char)
print uni_char
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment