def readIDENT(stream):
    """
    Read a Variable-Length Identifier from given stream. Note: some of DLIS file vendor doesn't follow the standard,
    for example whitespace is included also some not of non ASCII char are included, so in case it failed to decode with
    ASCII, we will also try with CP1252.

    :type stream: FileIO or BytesIO
    :param stream: Where to read from

    :return: result
    :rtype: str
    """
    l = stream.read(1)[0]
    payload = stream.read(l)
    try:
        return payload.decode('ascii')
    except UnicodeDecodeError:
        return payload.decode('cp1252')
