Unknown encoding ‘UTF-16′ when running PAR Packaged Perl script

August 27, 2008 at 3:24 pm · Written by Jalada · Filed under Software

MixWizard expressed interest in trying out my Compilation Tag Modifier script, but I agree having to install Strawberry Perl and compile a bunch of modules on Windows is a pain, so I looked into packaging the script into an EXE complete with modules. PAR Packager seemed a good choice, so I used that and gave him the EXE. But he found that it wouldn’t work, it would crash like this:

Finding directories...done, found 276 directories
Checking directories for valid music files...done, now have 247 directories
Finding directories with more than 2 artists...
Unknown encoding 'UTF-16' at MP3/Tag/ID3v2.pm line 1921

I tried using an eval statement to catch error messages and ignore them, but that didn’t seem to work. I couldn’t understand why the script ran fine on it’s own, but didn’t when packaged together. I googled around a bit, and discovered someone having a similar trouble, and there was a solution. I tried it, and it now works!

The problem was, the Encode module uses an eval statement of it’s own, and PAR Packager doesn’t know what modules that will load without actually running the script. So I ran the script myself with an extra line of code:

print STDERR "$_\n" for grep {/Encode/} sort keys %INC;

Which allowed me to see what encode modules are loaded, and then I ‘use’d them explicitly in the script. I packaged it again, and now it works!

I’ll probably be releasing a packaged EXE soon, I just need MixWizard to test it himself.

Share:
  • Digg
  • Reddit
  • TwitThis
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Tumblr

Comments are closed.