def encode_base64(self, s): """ s will be always unicode. Return byte. """ if is_unicode(s): s = self.toByte(s) return base64.b64encode(s)
def urlencode(self): "Return the encoded string query. Return bytestring." origin = copy.deepcopy(self.__dict__) data = self.__encode(self.__dict__) # urlencode returns quote string result = urlencode(self.__dict__) self.__dict__ = origin if is_unicode(result): result = result.encode('utf-8') return result