MCPcopy Index your code
hub / github.com/httpie/cli / smart_decode

Function smart_decode

httpie/encoding.py:32–41  ·  view source on GitHub ↗

Decode `content` using the given `encoding`. If no `encoding` is provided, the best effort is to guess it from `content`. Unicode errors are replaced.

(content: ContentBytes, encoding: str)

Source from the content-addressed store, hash-verified

30
31
32def smart_decode(content: ContentBytes, encoding: str) -> Tuple[str, str]:
33 """Decode `content` using the given `encoding`.
34 If no `encoding` is provided, the best effort is to guess it from `content`.
35
36 Unicode errors are replaced.
37
38 """
39 if not encoding:
40 encoding = detect_encoding(content)
41 return content.decode(encoding, 'replace'), encoding
42
43
44def smart_encode(content: str, encoding: str) -> bytes:

Callers 1

decode_chunkMethod · 0.85

Calls 2

detect_encodingFunction · 0.85
decodeMethod · 0.80

Tested by

no test coverage detected