From f226bdbf4e06aa8ca787e34b0c626965ac526f28 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 2 Jul 2019 19:32:17 +0200 Subject: Refs #30608 -- Added django.utils.encoding.punycode(). --- django/utils/encoding.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'django/utils/encoding.py') diff --git a/django/utils/encoding.py b/django/utils/encoding.py index 94b63762db..2e2ad44e31 100644 --- a/django/utils/encoding.py +++ b/django/utils/encoding.py @@ -218,6 +218,11 @@ def escape_uri_path(path): return quote(path, safe="/:@&+$,-_.!~*'()") +def punycode(domain): + """Return the Punycode of the given domain if it's non-ASCII.""" + return domain.encode('idna').decode('ascii') + + def repercent_broken_unicode(path): """ As per section 3.2 of RFC 3987, step three of converting a URI into an IRI, -- cgit v1.3