<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def encode_cookie_value(data, quote=default_cookie_quote):
 """URL-encode strings to make them safe for a cookie value. By default this uses urllib quoting, as used in many other cookie implementations and in other Python code, instead of an ad hoc escaping mechanism which includes backslashes (these also being illegal chars in RFC 6265). """

    if data is None:
        return None

    # encode() to ASCII bytes so quote won't crash on non-ASCII.
    # but doing that to bytes objects is nonsense.
    # On Python 2 encode crashes if s is bytes containing non-ASCII.
    # On Python 3 encode crashes on all byte objects.
    if not isinstance(data, bytes):
        data = data.encode("utf-8")

    # URL encode data so it is safe for cookie value
    quoted = quote(data)

    # Don't force to bytes, so that downstream can use proper string API rather
    # than crippled bytes, and to encourage encoding to be done just once.
    return quoted