module documentation

Undocumented

Function escape​_uri​_path Escape the unsafe characters from the path portion of a Uniform Resource Identifier (URI).
Function filepath​_to​_uri Convert a file system path to a URI portion that is suitable for inclusion in a URL.
Function force​_bytes Similar to smart_bytes, except that lazy instances are resolved to strings, rather than kept as lazy objects.
Function force​_str Similar to smart_str(), except that lazy instances are resolved to strings, rather than kept as lazy objects.
Function iri​_to​_uri Convert an Internationalized Resource Identifier (IRI) portion to a URI portion that is suitable for inclusion in a URL.
Function is​_protected​_type Determine if the object instance is of a protected type.
Function smart​_bytes Return a bytestring version of 's', encoded as specified in 'encoding'.
Function smart​_str Return a string representing 's'. Treat bytestrings using the 'encoding' codec.
Function uri​_to​_iri Convert a Uniform Resource Identifier(URI) into an Internationalized Resource Identifier(IRI).
Constant DEFAULT​_LOCALE​_ENCODING Undocumented
Class ​Django​Unicode​Decode​Error Undocumented
Function get​_system​_encoding The encoding of the default system locale. Fallback to 'ascii' if the #encoding is unsupported by Python or could not be determined. See tickets #10335 and #5846.
Function punycode Return the Punycode of the given domain if it's non-ASCII.
Function repercent​_broken​_unicode As per section 3.2 of RFC 3987, step three of converting a URI into an IRI, repercent-encode any octet produced that is not part of a strictly legal UTF-8 octet sequence.
Constant ​_PROTECTED​_TYPES Undocumented
Variable ​_ascii​_ranges Undocumented
Variable ​_hexdig Undocumented
Variable ​_hextobyte Undocumented
def escape_uri_path(path):
Escape the unsafe characters from the path portion of a Uniform Resource Identifier (URI).
def filepath_to_uri(path):

Convert a file system path to a URI portion that is suitable for inclusion in a URL.

Encode certain chars that would normally be recognized as special chars for URIs. Do not encode the ' character, as it is a valid character within URIs. See the encodeURIComponent() JavaScript function for details.

def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):

Similar to smart_bytes, except that lazy instances are resolved to strings, rather than kept as lazy objects.

If strings_only is True, don't convert (some) non-string-like objects.

def force_str(s, encoding='utf-8', strings_only=False, errors='strict'):

Similar to smart_str(), except that lazy instances are resolved to strings, rather than kept as lazy objects.

If strings_only is True, don't convert (some) non-string-like objects.

def iri_to_uri(iri):

Convert an Internationalized Resource Identifier (IRI) portion to a URI portion that is suitable for inclusion in a URL.

This is the algorithm from section 3.1 of RFC 3987, slightly simplified since the input is assumed to be a string rather than an arbitrary byte stream.

Take an IRI (string or UTF-8 bytes, e.g. '/I ♥ Django/' or b'/I ♥ Django/') and return a string containing the encoded result with ASCII chars only (e.g. '/I%20%E2%99%A5%20Django/').

def is_protected_type(obj):

Determine if the object instance is of a protected type.

Objects of protected types are preserved as-is when passed to force_str(strings_only=True).

def smart_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):

Return a bytestring version of 's', encoded as specified in 'encoding'.

If strings_only is True, don't convert (some) non-string-like objects.

def smart_str(s, encoding='utf-8', strings_only=False, errors='strict'):

Return a string representing 's'. Treat bytestrings using the 'encoding' codec.

If strings_only is True, don't convert (some) non-string-like objects.

def uri_to_iri(uri):

Convert a Uniform Resource Identifier(URI) into an Internationalized Resource Identifier(IRI).

This is the algorithm from section 3.2 of RFC 3987, excluding step 4.

Take an URI in ASCII bytes (e.g. '/I%20%E2%99%A5%20Django/') and return a string containing the encoded result (e.g. '/I%20♥%20Django/').

DEFAULT_LOCALE_ENCODING =

Undocumented

Value
get_system_encoding()
def get_system_encoding():
The encoding of the default system locale. Fallback to 'ascii' if the #encoding is unsupported by Python or could not be determined. See tickets #10335 and #5846.
def punycode(domain):
Return the Punycode of the given domain if it's non-ASCII.
def repercent_broken_unicode(path):
As per section 3.2 of RFC 3987, step three of converting a URI into an IRI, repercent-encode any octet produced that is not part of a strictly legal UTF-8 octet sequence.
_PROTECTED_TYPES =

Undocumented

Value
(type(None),
 int,
 float,
 Decimal,
 datetime.datetime,
 datetime.date,
 datetime.time)
_ascii_ranges =

Undocumented

_hexdig: str =

Undocumented

_hextobyte =

Undocumented