def s3_unicode(s, encoding="utf-8"):

    if type(s) is unicode:
        return s
    try:
        if not isinstance(s, basestring):
            if hasattr(s, "__unicode__"):
                s = unicode(s)
            else:
                try:
                    s = unicode(str(s), encoding, "strict")
                except UnicodeEncodeError:
                    if not isinstance(s, Exception):
                        raise
                    s = " ".join([s3_unicode(arg, encoding) for arg in s])
        else:
            s = s.decode(encoding)
    except UnicodeDecodeError:
        if not isinstance(s, Exception):
            raise
        else:
            s = " ".join([s3_unicode(arg, encoding) for arg in s])
    return s

# -------------------------------------------------------------------------
Encode request into client_message
dataset/ETHPy150Open sahana/eden/static/scripts/tools/csv2xml.py/s3_unicode--crossover with--dataset/ETHPy150Open hazelcast/hazelcast-python-client/hazelcast/protocol/codec/semaphore_acquire_codec.py/encode_request