werkzeug.uri_to_iri

werkzeug.uri_to_iri(uri, charset='utf-8', errors='replace')[source]

Converts a URI in a given charset to a IRI.

Examples for URI versus IRI:

>>> uri_to_iri(b'http://xn--n3h.net/')
u'http://\u2603.net/'
>>> uri_to_iri(b'http://%C3%BCser:p%C3%A4ssword@xn--n3h.net/p%C3%A5th')
u'http://\xfcser:p\xe4ssword@\u2603.net/p\xe5th'

Query strings are left unchanged:

>>> uri_to_iri('/?foo=24&x=%26%2f')
u'/?foo=24&x=%26%2f'

New in version 0.6.

Parameters:
  • uri – The URI to convert.
  • charset – The charset of the URI.
  • errors – The error handling on decode.