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)
| 827 | # django.utils.encoding.force_str() for parsing URLs and form inputs. Thus, |
| 828 | # this slightly more restricted function, used by QueryDict. |
| 829 | def 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 | |
| 843 | def split_domain_port(host): |
no outgoing calls
no test coverage detected