MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / unquote

Function unquote

tools/python-3.11.9-amd64/Lib/urllib/parse.py:659–684  ·  view source on GitHub ↗

Replace %xx escapes by their single-character equivalent. The optional encoding and errors parameters specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. By default, percent-encoded sequences are decoded with UTF-8, a

(string, encoding='utf-8', errors='replace')

Source from the content-addressed store, hash-verified

657_asciire = re.compile('([\x00-\x7f]+)')
658
659def unquote(string, encoding='utf-8', errors='replace'):
660 """Replace %xx escapes by their single-character equivalent. The optional
661 encoding and errors parameters specify how to decode percent-encoded
662 sequences into Unicode characters, as accepted by the bytes.decode()
663 method.
664 By default, percent-encoded sequences are decoded with UTF-8, and invalid
665 sequences are replaced by a placeholder character.
666
667 unquote('abc%20def') -> 'abc def'.
668 """
669 if isinstance(string, bytes):
670 return unquote_to_bytes(string).decode(encoding, errors)
671 if '%' not in string:
672 string.split
673 return string
674 if encoding is None:
675 encoding = 'utf-8'
676 if errors is None:
677 errors = 'replace'
678 bits = _asciire.split(string)
679 res = [bits[0]]
680 append = res.append
681 for i in range(1, len(bits), 2):
682 append(unquote_to_bytes(bits[i]).decode(encoding, errors))
683 append(bits[i + 1])
684 return ''.join(res)
685
686
687def parse_qs(qs, keep_blank_values=False, strict_parsing=False,

Callers 8

_parseMethod · 0.90
proxy_openMethod · 0.90
ftp_openMethod · 0.90
url2pathnameFunction · 0.90
_open_generic_httpMethod · 0.90
open_ftpMethod · 0.90
open_dataMethod · 0.90
unquote_plusFunction · 0.70

Calls 5

unquote_to_bytesFunction · 0.85
appendClass · 0.50
decodeMethod · 0.45
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected