JeevanJames / Id3

Library to read, modify and write ID3 & Lyrics3 tags in MP3 files. Provides an extensible framework for retrieving ID3 information from online services.
Apache License 2.0
41 stars 17 forks source link

fix unicode string decoding #60

Open sc630 opened 2 years ago

sc630 commented 2 years ago

There was an error in detecting the correct termination bytes of unicode strings. As result the last character of the string was corrupted and one byte was left in the buffer, thus the following data wasn't decoded correctly (in my example a picture frame for title cover). When the data is written back, the frames are encoded correctly, but with the corrupt data in memory. Example: the string "The" in unicode is encoded as follows: $FF $FE $54 $00 $68 $00 $65 $00 $00 $00

So I implemented the unicode decoding regarding two-byte characters and little-endian or big-endian encoding corresponding to the byte order marker (preamble). I tryed to simplify the decoding function for better readability and added some comments with the frame specifications for orientation.

also fixed: