code: def uri_to_iri(uri, charset='utf-8', errors='replace'):
      r
      if isinstance(uri, tuple):
          uri = url_unparse(uri)
      uri = url_parse(to_unicode(uri, charset))
      path = url_unquote(uri.path, charset, errors, '/;?')
      query = url_unquote(uri.query, charset, errors, ';/?:@&=+,$')
      fragment = url_unquote(uri.fragment, charset, errors, ';/?:@&=+,$')
      return url_unparse((uri.scheme, uri.decode_netloc(),
                          path, query, fragment))
docs: r"""
      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'
  
      .. versionadded:: 0.6
  
      :param uri: The URI to convert.
      :param charset: The charset of the URI.
      :param errors: The error handling on decode.