def encode(cls, v):
        for enc in cls.encodings:
            try:
                return v.encode(enc)
            except UnicodeEncodeError:
                continue

        if cls.protocol == (1, 1) and cls.use_rfc_2047:
            # Encode RFC-2047 TEXT
            # (e.g. u"\u8200" -> "=?utf-8?b?6IiA?=").
            # We do our own here instead of using the email module
            # because we never want to fold lines--folding has
            # been deprecated by the HTTP working group.
            v = b2a_base64(v.encode('utf-8'))
            return (ntob('=?utf-8?b?') + v.strip(ntob('\n')) + ntob('?='))

        raise ValueError("Could not encode header part %r using "
                         "any of the encodings %r." %
                         (v, cls.encodings))
A generic template view passes kwargs as context.
dataset/ETHPy150Open clips/pattern/pattern/server/cherrypy/cherrypy/lib/httputil.py/HeaderMap.encode--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.5/tests/regressiontests/generic_views/base.py/TemplateViewTest.test_template_params