I would like to force UNICODE encoding (UCS-2 Big Endian to be exact) for the content of the UserComment tag, even when it doesn't contain any special character.
Is there a command line option or any other chance of doing this?
See FAQ #10 (https://exiftool.org/faq.html#Q10), EXIF section.
The bottom line is that you can't force ExifTool to use UNICODE encoding when writing UserComment if the string contains all ASCII characters.
- Phil
Edit: Wait. Strike that. You could override ExifTool's UserComment tag with a user-defined tag that does exactly what you want. Take a look at the UserComment definition here (https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/Exif.pm#L2315). You would copy this definition and change the RawConvInv to this:
RawConvInv => '"UNICODE\0" . $self->Encode($val,"UTF16",$self->GetNewValue("ExifUnicodeByteOrder"))',
So would this be correct for a stand alone config file?
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Exif::Main' => {
0x9286 => {
Name => 'UserComment',
# I have seen other applications write it incorrectly as 'string' or 'int8u'
Format => 'undef',
Writable => 'undef',
RawConv => 'Image::ExifTool::Exif::ConvertExifText($self,$val,1,$tag)',
# (starts with "ASCII\0\0\0", "UNICODE\0", "JIS\0\0\0\0\0" or "\0\0\0\0\0\0\0\0")
RawConvInv => '"UNICODE\0" . $self->Encode($val,"UTF16",$self->GetNewValue("ExifUnicodeByteOrder"))',
# SHOULD ADD SPECIAL LOGIC TO ALLOW CONDITIONAL OVERWRITE OF
# "UNKNOWN" VALUES FILLED WITH SPACES
},
},
);
Exactly.
- Phil