Skip to content

Instantly share code, notes, and snippets.

@hyunjun
Forked from kimdwkimdw/guide.md
Created July 6, 2014 13:57
Show Gist options
  • Save hyunjun/8b2068c17e86d2f63153 to your computer and use it in GitHub Desktop.
Save hyunjun/8b2068c17e86d2f63153 to your computer and use it in GitHub Desktop.
'''
Python Encoding cheatsheet
Mostly for korean.
All below items are True
'''
"한글" != u"한글"
"한글" == '\xed\x95\x9c\xea\xb8\x80'
u"한글" == u'\ud55c\uae00'
"한글".decode("utf-8") == u"한글"
"한글" == u"한글".encode("utf-8")
"\ud55c\uae00".decode('unicode_escape') == u"한글"
# #2 > #1 #2 is faster than #1.
"한글".decode("utf-8") in u"asdf한글asdf" #1
"한글" in u"asdf한글asdf".encode("utf-8") #2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment