MCPcopy Create free account
hub / github.com/catboost/catboost / unquote_binary

Function unquote_binary

library/python/strings/strings.py:278–295  ·  view source on GitHub ↗

Replace %xx escapes by their single-character equivalent. By default, percent-encoded sequences are replaced by ASCII character or byte code, and invalid sequences are replaced by a placeholder character. unquote('abc%20def') -> 'abc def' unquote('abc%FFdef') -> 'abc\xffdef' unq

(string)

Source from the content-addressed store, hash-verified

276
277
278def unquote_binary(string):
279 """Replace %xx escapes by their single-character equivalent.
280 By default, percent-encoded sequences are replaced by ASCII character or
281 byte code, and invalid sequences are replaced by a placeholder character.
282
283 unquote('abc%20def') -> 'abc def'
284 unquote('abc%FFdef') -> 'abc\xffdef'
285 unquote('%no') -> '%no'
286 """
287 bits = string.split(b"%")
288 if len(bits) == 1:
289 return bits[0]
290
291 res = [bits[0]]
292 for item in bits[1:]:
293 res.append(_hextobyte.get(item[:2], b"%"))
294 res.append(item if res[-1] == b"%" else item[2:])
295 return b"".join(res)

Callers 1

parse_qsl_binaryFunction · 0.85

Calls 5

lenFunction · 0.85
splitMethod · 0.45
appendMethod · 0.45
getMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected