Ticket #18888: patch_id3lib_3.8.3_UTF16_writing_bug.diff

File patch_id3lib_3.8.3_UTF16_writing_bug.diff, 1.5 KB (added by yuk_fai@…, 15 years ago)

reported patch

  • id3lib-3.8.3

    diff -ruN id3lib-3.8.3.orig/ChangeLog id3lib-3.8.3/ChangeLog
    old new  
     12006-02-17  Jerome Couderc
     2
     3    * Patch from Spoon to fix UTF-16 writing bug
     4      http://sourceforge.net/tracker/index.php?func=detail&aid=1016290&group_id=979&atid=300979
     5
    162003-03-02 Sunday 17:38   Thijmen Klok <thijmen@id3lib.org>
    27
    38        * THANKS (1.20): added more people
  • src/io_helpers.cpp

    diff -ruN id3lib-3.8.3.orig/src/io_helpers.cpp id3lib-3.8.3/src/io_helpers.cpp
    old new  
    363363    // Write the BOM: 0xFEFF
    364364    unicode_t BOM = 0xFEFF;
    365365    writer.writeChars((const unsigned char*) &BOM, 2);
     366    // Patch from Spoon : 2004-08-25 14:17
     367    //   http://sourceforge.net/tracker/index.php?func=detail&aid=1016290&group_id=979&atid=300979
     368    // Wrong code
     369    //for (size_t i = 0; i < size; i += 2)
     370    //{
     371    //  unicode_t ch = (data[i] << 8) | data[i+1];
     372    //  writer.writeChars((const unsigned char*) &ch, 2);
     373    //}
     374    // Right code
     375    unsigned char *pdata = (unsigned char *) data.c_str();
    366376    for (size_t i = 0; i < size; i += 2)
    367377    {
    368       unicode_t ch = (data[i] << 8) | data[i+1];
     378      unicode_t ch = (pdata[i] << 8) | pdata[i+1];
    369379      writer.writeChars((const unsigned char*) &ch, 2);
    370380    }
     381    // End patch
    371382  }
    372383  return writer.getCur() - beg;
    373384}