code: def sanitize_string(string_or_unicode):
      
      if isinstance(string_or_unicode, unicode):
          return string_or_unicode.strip()
      elif isinstance(string_or_unicode, str):
          return string_or_unicode.decode('utf-8').strip()
      else:  # e.g. if input is None
          return u''
docs: remove leading/trailing whitespace and always return unicode.