'Escape a unicode string in an OAuth-compatible fashion.'

def _escape(self, s):

    safe = '~'
    s = (s.encode('utf-8') if isinstance(s, six.text_type) else s)
    s = urlparse.quote(s, safe)
    if isinstance(s, six.binary_type):
        s = s.decode('utf-8')
    return s
