Tuesday, June 5, 2007

Converter CJK Encoding to Unicode

encc = ""
def zh2unicode(stri):
"""Auto converter encodings to unicode

It will test utf8,gbk,big5,jp,kr to converter"""
global encc
for c in ('utf-8', 'gbk', 'big5', 'jp', 'euc_kr','utf16','utf32'):
encc = c
try:
return stri.decode(c)
except:
pass
encc = 'unk'
return stri

No comments: