def unisafe(val):
    """safely convert to unicode

    >>> unisafe(None)
    ''

    >>> unisafe(b'123')
    '123'

    >>> unisafe(
    ...     b'\\xe3\\x81\\x93\\xe3\\x82\\x93\\xe3\\x81\\xab\\xe3\\x81'
    ...     b'\\xa1\\xe3\\x81\\xaf\\xe4\\xb8\\x96\\xe7\\x95\\x8c'
    ... )
    'こんにちは世界'

    >>> unisafe(1)
    '1'

    """
    if val is None:
        return ''
    elif isinstance(val, bytes):
        try:
            val = val.decode('utf-8')
        except:
            val = val.decode('Latin-1')
    elif not isinstance(val, str):
        val = str(val)
    return val