archrelease: copy trunk to extra-x86_64
[arch-packages.git] / id3lib / trunk / 30-fix-utf16.patch
blob3d3f50fed65399b24912c61fc8709e2b3bf49dec
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
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
10 2003-03-02 Sunday 17:38 Thijmen Klok <thijmen@id3lib.org>
12 * THANKS (1.20): added more people
13 --- a/src/io_helpers.cpp
14 +++ b/src/io_helpers.cpp
15 @@ -363,11 +363,22 @@
16 // Write the BOM: 0xFEFF
17 unicode_t BOM = 0xFEFF;
18 writer.writeChars((const unsigned char*) &BOM, 2);
19 + // Patch from Spoon : 2004-08-25 14:17
20 + // http://sourceforge.net/tracker/index.php?func=detail&aid=1016290&group_id=979&atid=300979
21 + // Wrong code
22 + //for (size_t i = 0; i < size; i += 2)
23 + //{
24 + // unicode_t ch = (data[i] << 8) | data[i+1];
25 + // writer.writeChars((const unsigned char*) &ch, 2);
26 + //}
27 + // Right code
28 + unsigned char *pdata = (unsigned char *) data.c_str();
29 for (size_t i = 0; i < size; i += 2)
31 - unicode_t ch = (data[i] << 8) | data[i+1];
32 + unicode_t ch = (pdata[i] << 8) | pdata[i+1];
33 writer.writeChars((const unsigned char*) &ch, 2);
35 + // End patch
37 return writer.getCur() - beg;