Unicode Conversion

Raphael Ho
  • Raphael Ho

    Raphael Ho - 2007-07-19

    I'm looking at a Unicode metadata conversion problem

    The hexdump on the id3 tag for track name says "ff fe 4a 53 35 5f db 98", but when importing the track, iconv spits its dummy.

    2007-07-19 13:24:48   ERROR: iconv: Invalid argument
    2007-07-19 13:24:48   ERROR: iconv: Incomplete multibyte sequence

    My 6 liner perl script works fine

    use MP3::Info qw(:all);
    use Encode;
    use utf8;
    binmode STDOUT, ":utf8";

    $file = $ARGV[0];
    my $mp3 = get_mp3tag($file);
    $ustring = $mp3->{TITLE} || "Unknown";
    $ustring = decode("utf-16", $ustring);

    This may be an iconv problem, I'm trying to figure it out. If anyone wants to jump in, feel free.

    Otherwise, watch this space.

    • Raphael Ho

      Raphael Ho - 2007-07-19

      Hmm... probably not an iconv problem... need to go read the mediatomb source code then.

      macmini:~/src rho$ hexdump test2.out
      0000000 fffe 4a53 355f db98
      macmini:~/src rho$ iconv -f utf-16 -t utf-8 test2.out
      半張飛macmini:~/src rho$

    • Jin

      Jin - 2007-07-19

      Are you sure that you specified the metadata-charset in the config.xml correctly?

      As I see from the example above, you are converting from utf-16, so that's what you need to add to your config.xml

      You may also need to set the filesystem-charset option too (in case your filenames are in a particular charset), see documentation for further details on those options.

      By default we detect the current charset from the system locale settings, but of course id3 tags can probably be just anything and we have to know what encoding exactly they are in so we can feed the proper parameters to iconv.

      Did those settings solve the problem?

    • Raphael Ho

      Raphael Ho - 2007-07-19

      Hey, Jin

      Forgot to mention that I already had this in my config.xml before i did the above.
        <import hidden-files="no">

      I had one file out of the entire collection that came out properly (somehow). Will go hunt that file down and look inside the ID3 tags to see what's different.




Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks