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')
| 714 | yield string[previous_match_end:] # Non-ASCII tail |
| 715 | |
| 716 | def unquote(string, encoding='utf-8', errors='replace'): |
| 717 | """Replace %xx escapes by their single-character equivalent. The optional |
| 718 | encoding and errors parameters specify how to decode percent-encoded |
| 719 | sequences into Unicode characters, as accepted by the bytes.decode() |
| 720 | method. |
| 721 | By default, percent-encoded sequences are decoded with UTF-8, and invalid |
| 722 | sequences are replaced by a placeholder character. |
| 723 | |
| 724 | unquote('abc%20def') -> 'abc def'. |
| 725 | """ |
| 726 | if isinstance(string, bytes): |
| 727 | return _unquote_impl(string).decode(encoding, errors) |
| 728 | if '%' not in string: |
| 729 | # Is it a string-like object? |
| 730 | string.split |
| 731 | return string |
| 732 | if encoding is None: |
| 733 | encoding = 'utf-8' |
| 734 | if errors is None: |
| 735 | errors = 'replace' |
| 736 | return ''.join(_generate_unquoted_parts(string, encoding, errors)) |
| 737 | |
| 738 | |
| 739 | def parse_qs(qs, keep_blank_values=False, strict_parsing=False, |
no test coverage detected