'Encode the string for inclusion in a URL'

@staticmethod
def _encode(s):

    if isinstance(s, six.text_type):
        for (char, repl) in URL_CHARACTERS.items():
            s = s.replace(char, repl)
        s = s.encode('utf-8', 'ignore')
    return urllib.parse.quote(s)
