Main Menu

Problem using WriteInfo

Started by Archive, May 12, 2010, 08:53:51 AM

Previous topic - Next topic

Archive

[Originally posted by tschnebeck on 2005-10-17 15:11:54-07]

Hi,

when using Writer.pl I get this error, when embedding exiftool into C++.
I can test later if this also happens with the perl interpreter via perl -e:

"You may need to build a new perl executable which either supports
dynamic loading or has the Encode module statically linked into it.

at /usr/lib/perl5/site_perl/5.8.6/Image/ExifTool/Writer.pl line 124"

Bye

  Thorsten

Archive

[Originally posted by exiftool on 2005-10-17 15:50:01-07]

Hi Thorsten,

 I'm not sure why this gives an error while all my other dynamic links work fine (all ExifTool modules are linked dyamically).

I recently added the Encode use (in version 5.67).  It fixes a problem if the users passes UTF8-encoded strings via the API, but if you're going through the exiftool script, this isn't a problem. The Encode module should be standard with Perl 5.8 or greater, so I'm surprised you get this error.  However, maybe we can avoid this error by wrapping the 'require' in an 'eval'.  Try this:

Code:
Replace the following lines (124 and 125) in lib/Image/ExifTool/Writer.pl

        require Encode;
        Encode::_utf8_off($value);

with

        eval 'require Encode' and Encode::_utf8_off($value);

If this works for you, I'll make this change to the official version.

Archive

[Originally posted by tschnebeck on 2005-10-17 17:00:03-07]

Not better:

"Undefined subroutine &Encode::_utf8_off called at /usr/lib/perl5/site_perl/5.8.6/Image/ExifTool/Writer.pl line 125 during global destruction."

Looks like my system has not the correct Encode module(?) How can I check, how can I install via cpan?

Bye

  Thorsten

Archive

[Originally posted by exiftool on 2005-10-17 17:13:22-07]

I don't understand how the "eval 'require Encode'" can be successful without Encode::_utf8_off() being available.

If it is calling _utf8_off(), then the Encode module must have been loaded, so you must have it.  It doesn't make sense.

The following line WILL work instead, but is slower so I would rather not do this in the official version:

Code:
   pack('C*', unpack('C*', $value));

So I'm at a bit of a loss trying to get something that works for everyone yet doesn't compromise performance.

Archive

[Originally posted by tschnebeck on 2005-10-17 17:59:28-07]

Hmm, I read a little bit in Usenet but did not find anything helpful. Oh, so said _utf8_off() is evil and a rally bad thing ;-)

pack('C*', unpack('C*', $value)); works - or better it runs - my C++ program still crashs when writing. But this is now my problem :-)

Bye

  Thorsten

Archive

[Originally posted by exiftool on 2005-10-17 18:11:01-07]

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:

Code:
       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.