Posted on 2005-10-17 18:11:01-07 by exiftool in response to 1187
Re: Problem using WriteInfo
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.

Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.