def recode_path_qs(self, path, qs):
        """Recode app response path query string."""
        # This isn't perfect; if the given PATH_INFO is in the
        # wrong encoding, it may fail to match the appropriate config
        # section URI. But meh.
        old_enc = self.environ.get('wsgi.url_encoding', 'ISO-8859-1')
        new_enc = self.cpapp.find_config(
            self.environ.get('PATH_INFO', ''),
            'request.uri_encoding',
            'utf-8',
        )
        if new_enc.lower() == old_enc.lower():
            return

        # Even though the path and qs are unicode, the WSGI server
        # is required by PEP 3333 to coerce them to ISO-8859-1
        # masquerading as unicode. So we have to encode back to
        # bytes and then decode again using the "correct" encoding.
        try:
            return (
                path.encode(old_enc).decode(new_enc),
                qs.encode(old_enc).decode(new_enc),
            )
        except (UnicodeEncodeError, UnicodeDecodeError):
            # Just pass them through without transcoding and hope.
            pass
Recode app response path query string.
cherrypy/_cpwsgi.py