in reply to ID3 tag version 2.4.0 Pack and Unpack

I believe that your problem is due to this part of the spec you linked to:

Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings:

$00
ISO-8859-1 [ISO-8859-1]. Terminated with $00.
$01
UTF-16 [UTF-16] encoded Unicode [UNICODE] with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00.
$02
UTF-16BE [UTF-16] encoded Unicode [UNICODE] without BOM. Terminated with $00 00.
$03
UTF-8 [UTF-8] encoded Unicode [UNICODE]. Terminated with $00.

You don't notice that your "read" program is sending the "\0" byte at the front of such values.

- tye        

  • Comment on Re: ID3 tag version 2.4.0 Pack and Unpack (text encoding byte)

Replies are listed 'Best First'.
Re^2: ID3 tag version 2.4.0 Pack and Unpack (text encoding byte)
by thanos1983 (Parson) on Sep 04, 2014 at 22:52 UTC

    Hello tye,

    First of all I want to say thank you for your time and effort to assist me with my problem.

    My read program ends with "\0"? Could you please help me a bit more here. I am a bit confused, I thought all strings in Perl end automatically with "\0", I can not avoid that.

    I will look again and again the code in order to understand what you mean.

    Thanks again for your time and effort.

    Seeking for Perl wisdom...on the process of learning...not there...yet!

      Before the write, your read program is actually writing out "Third Part Frame id: TPE1 Frame Size: 10 Flags: \0An artist" and "Third Part Frame id: TALB Frame Size: 9 Flags: \0An album", but those "\0" bytes are not visible.

      Your writer needs to not deal with just the frame type, frame length, and flags. It also has to deal with (for some frame types) one more byte which I quoted the documentation for above.

      - tye        

        Hello again tye,

        I understand what you mean by the null terminating character on the strings. But on the flag how can I remove it? I assume you mean the part that I apply if ($flags == 0). I assume, I tried to apply chop right after the part ( $flags ) = unpack ( "h" , $lines ); I apply chop($flags);. On the writing part I still have the problem. Unless if I miss understood.

        I know that I am missing somewhere one byte and I can not understand what is my error.

        Seeking for Perl wisdom...on the process of learning...not there...yet!
      I thought all strings in Perl end automatically with "\0"

      Don’t confuse Perl with C here. Consider:

      12:23 >perl -MData::Dump -wE "my $s = qq[foo\0bar]; dd $s; say length( +$s); say qq[|$s|];" "foo\0bar" 7 |foo bar| 12:23 >

      If Perl used the null terminator for strings as C does, the above would print |foo|, not |foo bar|.

      Hope that helps,

      Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

        Hello Athanasiis,

        Thank you for your time and effort. It does help me to understand, a few things. But still I have not figure out how to solve my problem. Or let me put it this way, I have not figure it out why id3info produces different output than mine. I still can not understand, where I am going wrong and I add one extra bit. Well in case that $00 was adding the extra bit, by applying chop($flags) should have done the job but still the same problem.

        Thank you again for your time and effort.

        Seeking for Perl wisdom...on the process of learning...not there...yet!