On this page
URL Helpers
werkzeug.urls.iri_to_uri(iri)
-
Convert an IRI to a URI. All non-ASCII and unsafe characters are quoted. If the URL has a domain, it is encoded to Punycode.
>>> iri_to_uri('http://\u2603.net/p\xe5th?q=\xe8ry%DF') 'http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF'
Changed in version 3.0: Passing a tuple or bytes, the
charset
anderrors
parameters, and thesafe_conversion
parameter, are removed.Changelog
Changed in version 2.3: Which characters remain unquoted is specific to each part of the URL.
Changed in version 0.15: All reserved characters remain unquoted. Previously, only some reserved characters were left unquoted.
Changed in version 0.9.6: The
safe_conversion
parameter was added.New in version 0.6.
werkzeug.urls.uri_to_iri(uri)
-
Convert a URI to an IRI. All valid UTF-8 characters are unquoted, leaving all reserved and invalid characters quoted. If the URL has a domain, it is decoded from Punycode.
>>> uri_to_iri("http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF") 'http://\u2603.net/p\xe5th?q=\xe8ry%DF'
Changed in version 3.0: Passing a tuple or bytes, and the
charset
anderrors
parameters, are removed.Changelog
Changed in version 2.3: Which characters remain quoted is specific to each part of the URL.
Changed in version 0.15: All reserved and invalid characters remain quoted. Previously, only some reserved characters were preserved, and invalid bytes were replaced instead of left quoted.
New in version 0.6.
© 2007 Pallets
Licensed under the BSD 3-clause License.
https://werkzeug.palletsprojects.com/en/3.0.x/urls/