diff -N -U 3 -r id3lib-3.8.3-orig/ChangeLog id3lib-3.8.3/ChangeLog
--- id3lib-3.8.3-orig/ChangeLog	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/ChangeLog	2010-01-05 20:17:20.000000000 +0200
@@ -1,3 +1,8 @@
+2006-02-17  Jerome Couderc
+
+    * Patch from Spoon to fix UTF-16 writing bug
+      http://sourceforge.net/tracker/index.php?func=detail&aid=1016290&group_id=979&atid=300979
+
 2003-03-02 Sunday 17:38   Thijmen Klok <thijmen@id3lib.org>
 
 	* THANKS (1.20): added more people 
diff -N -U 3 -r id3lib-3.8.3-orig/configure id3lib-3.8.3/configure
--- id3lib-3.8.3-orig/configure	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/configure	2010-01-05 20:22:55.000000000 +0200
@@ -10296,7 +10296,7 @@
 
 for ac_header in \
   string                        \
-  iomanip.h                     \
+  iomanip                       \
 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
diff -N -U 3 -r id3lib-3.8.3-orig/configure.in id3lib-3.8.3/configure.in
--- id3lib-3.8.3-orig/configure.in	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/configure.in	2010-01-05 20:17:34.000000000 +0200
@@ -227,7 +227,7 @@
 )
 AC_CHECK_HEADERS(               \
   string                        \
-  iomanip.h                     \
+  iomanip                       \
   ,,AC_MSG_ERROR([Missing a vital header file for id3lib])
 )
 
diff -N -U 3 -r id3lib-3.8.3-orig/doc/Doxyfile.in id3lib-3.8.3/doc/Doxyfile.in
--- id3lib-3.8.3-orig/doc/Doxyfile.in	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/doc/Doxyfile.in	2010-01-05 20:17:20.000000000 +0200
@@ -263,14 +263,17 @@
 
 INPUT                  = ../src \
                          ../include/id3/field.h \
-                         ../include/id3/frame.h \
                          ../include/id3/globals.h \
+                         ../include/id3/helpers.h \
+                         ../include/id3/id3lib_frame.h \
+                         ../include/id3/id3lib_streams.h \
+                         ../include/id3/id3lib_strings.h \
                          ../include/id3/misc_support.h \
                          ../include/id3/reader.h \
                          ../include/id3/readers.h \
                          ../include/id3/sized_types.h \
                          ../include/id3/tag.h \
-                         ../include/id3/tag.h \
+                         ../include/id3/utils.h \
                          ../include/id3/writer.h \
                          ../include/id3/writers.h
 
diff -N -U 3 -r id3lib-3.8.3-orig/examples/demo_convert.cpp id3lib-3.8.3/examples/demo_convert.cpp
--- id3lib-3.8.3-orig/examples/demo_convert.cpp	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/examples/demo_convert.cpp	2010-01-05 20:17:20.000000000 +0200
@@ -84,7 +84,7 @@
   }
 }
 
-int main( unsigned int argc, char * const argv[])
+int main(int argc, char * const argv[])
 {
   flags_t ulFlag = ID3TT_ALL;
   gengetopt_args_info args;
diff -N -U 3 -r id3lib-3.8.3-orig/examples/demo_copy.cpp id3lib-3.8.3/examples/demo_copy.cpp
--- id3lib-3.8.3-orig/examples/demo_copy.cpp	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/examples/demo_copy.cpp	2010-01-05 20:17:20.000000000 +0200
@@ -81,7 +81,7 @@
   }
 }
 
-int main( unsigned int argc, char * const argv[])
+int main(int argc, char * const argv[])
 {
   int ulFlag = ID3TT_ID3;
   ID3D_INIT_DOUT();
diff -N -U 3 -r id3lib-3.8.3-orig/examples/demo_info.cpp id3lib-3.8.3/examples/demo_info.cpp
--- id3lib-3.8.3-orig/examples/demo_info.cpp	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/examples/demo_info.cpp	2010-01-05 20:17:20.000000000 +0200
@@ -309,7 +309,7 @@
 
 #define DEBUG
 
-int main( unsigned int argc, char * const argv[])
+int main(int argc, char * const argv[])
 {
   ID3D_INIT_DOUT();
 
diff -N -U 3 -r id3lib-3.8.3-orig/examples/demo_tag.cpp id3lib-3.8.3/examples/demo_tag.cpp
--- id3lib-3.8.3-orig/examples/demo_tag.cpp	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/examples/demo_tag.cpp	2010-01-05 20:17:20.000000000 +0200
@@ -46,7 +46,7 @@
     os << "v2";
 }
 
-int main( unsigned int argc, char * const argv[])
+int main(int argc, char * const argv[])
 {
   int ulFlag = ID3TT_ID3;
   ID3D_INIT_DOUT();
diff -N -U 3 -r id3lib-3.8.3-orig/include/id3/id3lib_strings.h id3lib-3.8.3/include/id3/id3lib_strings.h
--- id3lib-3.8.3-orig/include/id3/id3lib_strings.h	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/include/id3/id3lib_strings.h	2010-01-05 20:17:20.000000000 +0200
@@ -30,6 +30,7 @@
 #define _ID3LIB_STRINGS_H_
 
 #include <string>
+#include "string.h"
 
 #if (defined(__GNUC__) && (__GNUC__ >= 3) || (defined(_MSC_VER) && _MSC_VER > 1000))
 namespace std
diff -N -U 3 -r id3lib-3.8.3-orig/include/id3/writers.h id3lib-3.8.3/include/id3/writers.h
--- id3lib-3.8.3-orig/include/id3/writers.h	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/include/id3/writers.h	2010-01-05 20:17:20.000000000 +0200
@@ -30,7 +30,7 @@
 
 #include "id3/writer.h"
 #include "id3/id3lib_streams.h"
-//#include <string.h>
+#include "string.h"
 
 class ID3_CPP_EXPORT ID3_OStreamWriter : public ID3_Writer
 {
diff -N -U 3 -r id3lib-3.8.3-orig/src/field.cpp id3lib-3.8.3/src/field.cpp
--- id3lib-3.8.3-orig/src/field.cpp	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/src/field.cpp	2010-01-05 20:17:20.000000000 +0200
@@ -33,6 +33,8 @@
 #include "readers.h"
 #include <assert.h>
 
+#include "string.h"
+
 using namespace dami;
 
 // This is used for unimplemented frames so that their data is preserved when
diff -N -U 3 -r id3lib-3.8.3-orig/src/io_helpers.cpp id3lib-3.8.3/src/io_helpers.cpp
--- id3lib-3.8.3-orig/src/io_helpers.cpp	2003-03-02 02:23:00.000000000 +0200
+++ id3lib-3.8.3/src/io_helpers.cpp	2010-01-05 20:17:20.000000000 +0200
@@ -363,11 +363,22 @@
     // Write the BOM: 0xFEFF
     unicode_t BOM = 0xFEFF;
     writer.writeChars((const unsigned char*) &BOM, 2);
+    // Patch from Spoon : 2004-08-25 14:17
+    //   http://sourceforge.net/tracker/index.php?func=detail&aid=1016290&group_id=979&atid=300979
+    // Wrong code
+    //for (size_t i = 0; i < size; i += 2)
+    //{
+    //  unicode_t ch = (data[i] << 8) | data[i+1];
+    //  writer.writeChars((const unsigned char*) &ch, 2);
+    //}
+    // Right code
+    unsigned char *pdata = (unsigned char *) data.c_str();
     for (size_t i = 0; i < size; i += 2)
     {
-      unicode_t ch = (data[i] << 8) | data[i+1];
+      unicode_t ch = (pdata[i] << 8) | pdata[i+1];
       writer.writeChars((const unsigned char*) &ch, 2);
     }
+    // End patch
   }
   return writer.getCur() - beg;
 }
