def _encode_query_value(text, maximal=True):
    """
    Percent-encode a single query string key or value.
    """
    if maximal:
        bytestr = normalize('NFC', text).encode('utf8')
        return u''.join([_QUERY_VALUE_QUOTE_MAP[b] for b in bytestr])
    return u''.join([_QUERY_VALUE_QUOTE_MAP[t]
                     if t in _QUERY_VALUE_DELIMS else t for t in text])

    Percent-encode a single query string key or value.
    
stackoverflow/venv/lib/python3.6/site-packages/hyperlink/_url.py