MCPcopy
hub / github.com/django/django / bytes_to_text

Function bytes_to_text

django/http/request.py:829–840  ·  view source on GitHub ↗

Convert bytes objects to strings, using the given encoding. Illegally encoded input characters are replaced with Unicode "unknown" codepoint (\ufffd). Return any non-bytes objects without change.

(s, encoding)

Source from the content-addressed store, hash-verified

827# django.utils.encoding.force_str() for parsing URLs and form inputs. Thus,
828# this slightly more restricted function, used by QueryDict.
829def bytes_to_text(s, encoding):
830 """
831 Convert bytes objects to strings, using the given encoding. Illegally
832 encoded input characters are replaced with Unicode "unknown" codepoint
833 (\ufffd).
834
835 Return any non-bytes objects without change.
836 """
837 if isinstance(s, bytes):
838 return str(s, encoding, "replace")
839 else:
840 return s
841
842
843def split_domain_port(host):

Callers 4

__setitem__Method · 0.85
setlistMethod · 0.85
appendlistMethod · 0.85
setdefaultMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected