def unpack_wstring(self, offset, ilength=False):
        """
        Returns a UTF-16 decoded string from the relative offset with
        the given length, where each character is a wchar (2 bytes).
        The string does not include the final
        NULL character.
        Arguments:
        - `offset`: The relative offset from the start of the block.
        - `length`: (Optional) The length of the string. If no length is provided,
                       the string runs until a double NULL.
        Throws:
        - `UnicodeDecodeError`
        - `IndexError`
        """

        raw_bytes = self._buf[self._offset + offset:]

        # Trim to specified length
        if ilength:
            raw_bytes = raw_bytes[:ilength]

        # Ensure raw_bytes is even-length
        if len(raw_bytes) % 2:
            raw_bytes = raw_bytes[:-1]
        try:
            index = [raw_bytes[i:i + 2] for i in range(0, len(raw_bytes), 2)].index('\x00\x00')
            raw_bytes = raw_bytes[:index * 2]
        except ValueError:
            pass
        return raw_bytes.decode("utf-16-le")
dataset/ETHPy150Open williballenthin/shellbags/BinaryParser.py/Block.unpack_wstring/original