def decodeAny(string):
    """Try to decode the string from UTF-8 or latin9 encoding."""
    if isinstance(string, str):
        return string
    try:
        return string.decode('utf-8')
    except UnicodeError:
        # decoding latin9 never fails, since any byte is a valid
        # character there
        return string.decode('latin9')