code: def unicode_urlencode(obj, charset='utf-8', for_qs=False):
      
      if not isinstance(obj, string_types):
          obj = text_type(obj)
      if isinstance(obj, text_type):
          obj = obj.encode(charset)
      safe = not for_qs and b'/' or b''
      rv = text_type(url_quote(obj, safe))
      if for_qs:
          rv = rv.replace('%20', '+')
      return rv
docs: URL escapes a single bytestring or unicode string with the
      given charset if applicable to URL safe quoting under all rules
      that need to be considered under all supported Python versions.
  
      If non strings are provided they are converted to their unicode
      representation first.