urlstd.parse.string_percent_decode#

urlstd.parse.string_percent_decode(s: str) bytes#

Returns a percent-decoded byte sequence after encoding with utf-8.

Invalid surrogates will be replaced with U+FFFD.

Parameters:

s – A string to percent-decode.

Returns:

A percent-decoded byte sequence after encoding with utf-8.

Examples

>>> string_percent_decode('%f0%9f%8c%88').decode()
'🌈'
>>> string_percent_decode('\U0001f308').decode()
'🌈'
>>> string_percent_decode('\ud83c\udf08').decode()
'🌈'
>>> string_percent_decode('\udf08\ud83c').decode()
'\ufffd\ufffd'