ExifTool always outputs JSON in UTF-8, but the exiftool_metadata() function decodes the output using locale.getpreferredencoding(). On systems where the locale encoding is not UTF-8 (e.g., Windows with Chinese locale uses cp936/GBK), this can cause a UnicodeDecodeError when exiftool returns metadata containing non-ASCII characters.
Reproduction:
- Use Windows with Chinese locale (cp936)
- Run exiftool on an image with non-ASCII metadata
- exiftool_metadata() raises UnicodeDecodeError
Expected: JSON output decoded as UTF-8 (which is always the correct encoding for JSON per RFC 8259).
ExifTool always outputs JSON in UTF-8, but the exiftool_metadata() function decodes the output using locale.getpreferredencoding(). On systems where the locale encoding is not UTF-8 (e.g., Windows with Chinese locale uses cp936/GBK), this can cause a UnicodeDecodeError when exiftool returns metadata containing non-ASCII characters.
Reproduction:
Expected: JSON output decoded as UTF-8 (which is always the correct encoding for JSON per RFC 8259).