The following test image, where the Stable Diffusion prompt metadata embedded in EXIF UserComment contains non-ASCII characters, results in a 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte error.
Judging by your source code, it's because you're "parsing" the UNICODE variant (which this spec is unclear on but appears to be UTF-16) by discarding the high bytes and parsing the low bytes as UTF-8, which blows up when UTF-8's internal bytestream self-synchronization mechanism runs into bytes that aren't either 7-bit ASCII or serendipitously look like a valid multi-byte UTF-8 subsequence.

The following test image, where the Stable Diffusion prompt metadata embedded in EXIF UserComment contains non-ASCII characters, results in a
'utf-8' codec can't decode byte 0xff in position 0: invalid start byteerror.Judging by your source code, it's because you're "parsing" the
UNICODEvariant (which this spec is unclear on but appears to be UTF-16) by discarding the high bytes and parsing the low bytes as UTF-8, which blows up when UTF-8's internal bytestream self-synchronization mechanism runs into bytes that aren't either 7-bit ASCII or serendipitously look like a valid multi-byte UTF-8 subsequence.