def decode_argument(self, value, name=None): assert type(value) == bytes_type, repr(value) # use self.request.arguments directly to avoid recursion if 'encoding' in self.request.arguments: return value.decode(to_unicode(self.request.arguments['encoding'][0])) else: return value
def decode_argument(self, value, name=None): assert type(value) == bytes_type, repr(value) # use self.request.arguments directly to avoid recursion if 'encoding' in self.request.arguments: return value.decode( to_unicode(self.request.arguments['encoding'][0])) else: return value
def test_url_unescape(self): tests = [ ('%C3%A9', u'\u00e9', 'utf8'), ('%C3%A9', u'\u00c3\u00a9', 'latin1'), ('%C3%A9', utf8(u'\u00e9'), None), ] for escaped, unescaped, encoding in tests: # input strings to url_unescape should only contain ascii # characters, but make sure the function accepts both byte # and unicode strings. self.assertEqual(url_unescape(to_unicode(escaped), encoding), unescaped) self.assertEqual(url_unescape(utf8(escaped), encoding), unescaped)