$OpenBSD: patch-taglib_toolkit_tstring_cpp,v 1.1 2014/01/16 13:37:49 dcoppa Exp $

commit 3bf30af66c8fd77a88d9379a0956ddb2fc70dc20
Author: Tsuda Kageyu <tsuda.kageyu@gmail.com>
Date:   Wed Nov 6 17:01:21 2013 +0900

Fix ABI breakage in TagLib::String

--- taglib/toolkit/tstring.cpp.orig	Tue Oct  8 17:50:01 2013
+++ taglib/toolkit/tstring.cpp	Thu Jan 16 14:11:33 2014
@@ -209,8 +209,16 @@ String::String(const std::string &s, Type t)
 String::String(const wstring &s, Type t)
   : d(new StringPrivate())
 {
-  if(t == UTF16 || t == UTF16BE || t == UTF16LE)
+  if(t == UTF16 || t == UTF16BE || t == UTF16LE) {
+    // This looks ugly but needed for the compatibility with TagLib1.8. 
+    // Should be removed in TabLib2.0.
+    if (t == UTF16BE)
+      t = WCharByteOrder;
+    else if (t == UTF16LE)
+      t = (WCharByteOrder == UTF16LE ? UTF16BE : UTF16LE);
+
     copyFromUTF16(s.c_str(), s.length(), t);
+  }
   else {
     debug("String::String() -- A TagLib::wstring should not contain Latin1 or UTF-8.");
   }
@@ -219,8 +227,16 @@ String::String(const wstring &s, Type t)
 String::String(const wchar_t *s, Type t)
   : d(new StringPrivate())
 {
-  if(t == UTF16 || t == UTF16BE || t == UTF16LE)
+  if(t == UTF16 || t == UTF16BE || t == UTF16LE) {
+    // This looks ugly but needed for the compatibility with TagLib1.8. 
+    // Should be removed in TabLib2.0.
+    if (t == UTF16BE)
+      t = WCharByteOrder;
+    else if (t == UTF16LE)
+      t = (WCharByteOrder == UTF16LE ? UTF16BE : UTF16LE);
+
     copyFromUTF16(s, ::wcslen(s), t);
+  }
   else {
     debug("String::String() -- A const wchar_t * should not contain Latin1 or UTF-8.");
   }
