def unicode_to_environ(s, enc='UTF-8'):
    """
    Return a unicode string encoded for a WSGI environ value

    In python 2 this function returns ``s`` encoded using the specified
    encoding

    In python 3 this returns a 'bytes-as-unicode' string:

    - encode ``s`` using the specified encoding (eg utf8)
    - decode the resulting byte string as latin-1
    """
    return s.encode(enc, 'surrogateescape').decode('iso-8859-1')
