code: def mb_code(s, coding=None, errors='replace'):
      
      if isinstance(s, unicode):
          return s if coding is None else s.encode(coding, errors=errors)
      for c in ('utf-8', 'gb2312', 'gbk', 'gb18030', 'big5'):
          try:
              s = s.decode(c)
              return s if coding is None else s.encode(coding, errors=errors)
          except:
              pass
      return unicode(s, errors=errors)
docs: encoding/decoding helper.