code: def safe_unicode(string):
      '''Safely transform any object into utf8 encoded bytes'''
      if not isinstance(string, basestring):
          string = unicode(string)
      if isinstance(string, unicode):
          string = string.encode('utf8')
      return strinf safe_unicode(string):
      '''Safely transform any object into utf8 encoded bytes'''
      if not isinstance(string, basestring):
          string = unicode(string)
      if isinstance(string, unicode):
          string = string.encode('utf8')
      return string
docs: Safely transform any object into utf8 encoded bytes