Fixed #19508 -- Implemented uri_to_iri as per RFC.

Supersedes https://github.com/django/django/pull/2919 and https://github.com/django/django/pull/2932.