DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Python Utf8 Convert To Gbk

08.19.2009
| 6692 views |
  • submit to reddit
        // description of your code here

def utf2gbk(s,ignore=True):
    if ignore:
        return unicode(s,'utf8','ingore').encode('gb18030','ingore')
    else:
        return unicode(s,'utf8').encode('gb18030')