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, and i
(string, encoding='utf-8', errors='replace')
| 834 | yield string[previous_match_end:] # Non-ASCII tail |
| 835 | |
| 836 | def unquote(string, encoding='utf-8', errors='replace'): |
| 837 | """Replace %xx escapes by their single-character equivalent. The optional |
| 838 | encoding and errors parameters specify how to decode percent-encoded |
| 839 | sequences into Unicode characters, as accepted by the bytes.decode() |
| 840 | method. |
| 841 | By default, percent-encoded sequences are decoded with UTF-8, and invalid |
| 842 | sequences are replaced by a placeholder character. |
| 843 | |
| 844 | unquote('abc%20def') -> 'abc def'. |
| 845 | """ |
| 846 | if isinstance(string, bytes): |
| 847 | return _unquote_impl(string).decode(encoding, errors) |
| 848 | if '%' not in string: |
| 849 | # Is it a string-like object? |
| 850 | string.split |
| 851 | return string |
| 852 | if encoding is None: |
| 853 | encoding = 'utf-8' |
| 854 | if errors is None: |
| 855 | errors = 'replace' |
| 856 | return ''.join(_generate_unquoted_parts(string, encoding, errors)) |
| 857 | |
| 858 | |
| 859 | def parse_qs(qs, keep_blank_values=False, strict_parsing=False, |
no test coverage detected
searching dependent graphs…