30-fix-utf16.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Patch from 'Spoon' to fix issues with writing certain unicode characters
  2. --- a/ChangeLog
  3. +++ b/ChangeLog
  4. @@ -1,3 +1,8 @@
  5. +2006-02-17 Jerome Couderc
  6. +
  7. + * Patch from Spoon to fix UTF-16 writing bug
  8. + http://sourceforge.net/tracker/index.php?func=detail&aid=1016290&group_id=979&atid=300979
  9. +
  10. 2003-03-02 Sunday 17:38 Thijmen Klok <thijmen@id3lib.org>
  11. * THANKS (1.20): added more people
  12. --- a/src/io_helpers.cpp
  13. +++ b/src/io_helpers.cpp
  14. @@ -363,11 +363,22 @@
  15. // Write the BOM: 0xFEFF
  16. unicode_t BOM = 0xFEFF;
  17. writer.writeChars((const unsigned char*) &BOM, 2);
  18. + // Patch from Spoon : 2004-08-25 14:17
  19. + // http://sourceforge.net/tracker/index.php?func=detail&aid=1016290&group_id=979&atid=300979
  20. + // Wrong code
  21. + //for (size_t i = 0; i < size; i += 2)
  22. + //{
  23. + // unicode_t ch = (data[i] << 8) | data[i+1];
  24. + // writer.writeChars((const unsigned char*) &ch, 2);
  25. + //}
  26. + // Right code
  27. + unsigned char *pdata = (unsigned char *) data.c_str();
  28. for (size_t i = 0; i < size; i += 2)
  29. {
  30. - unicode_t ch = (data[i] << 8) | data[i+1];
  31. + unicode_t ch = (pdata[i] << 8) | pdata[i+1];
  32. writer.writeChars((const unsigned char*) &ch, 2);
  33. }
  34. + // End patch
  35. }
  36. return writer.getCur() - beg;
  37. }