def encode_filename(filename):
    """Given a filename to be used in a multipart/form-data, encode the name.

    Return the key and encoded filename.
    """
    if is_ascii(filename):
        return 'filename', '"{filename}"'.format(**locals())
    encoded = urllib.parse.quote(filename, encoding='utf-8')
    return 'filename*', "'".join(
        (
            'UTF-8',
            '',  # lang
            encoded,
        ),
    )
Given a filename to be used in a multipart/form-data, encode the name.

    Return the key and encoded filename.
    
cherrypy/test/test_http.py