I know _utf8_off() is evil, but it does the same thing as the unpack/pack and is a LOT faster. :-)
But I think I have figured out a more portable way of doing this which doesn't compromise performance on most systems:
if (eval 'require Encode; Encode::is_utf8($value)' or $@) {
$value = pack('C*', unpack('C*', $value));
}
This should work for you because the eval will fail, forcing the data to be repacked. And on systems that support Encode::is_utf8() the data is only repacked if necessary (which is almost never), so it won't slow things down too much. I have updated the my version of ExifTool with this change.
As you may have learned, this whole Perl/Unicode thing can be a bit confusing.
Thanks for your help in sorting this out.