From c03b91aed3c8306d6776046dbc052e87b32e4792 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 23 Jul 2014 14:56:18 +0900 Subject: [PATCH 1/2] Added a missing #include. --- taglib/toolkit/tutils.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index 2ade4d89..0874684a 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -44,6 +44,8 @@ # include #endif +#include + namespace TagLib { namespace Utils From 590405d87824391e666b04020cb233dacfa6c4f6 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 23 Jul 2014 15:35:49 +0900 Subject: [PATCH 2/2] Fixed handling UTF-16 byte order. --- taglib/toolkit/tstring.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 603455a1..c43d70b6 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -48,11 +48,6 @@ namespace { - inline unsigned short combine(unsigned char c1, unsigned char c2) - { - return (c1 << 8) | c2; - } - void UTF16toUTF8(const wchar_t *src, size_t srcLength, char *dst, size_t dstLength) { #ifdef HAVE_STD_CODECVT @@ -844,7 +839,12 @@ void String::copyFromUTF16(const char *s, size_t length, Type t) d->data.resize(length / 2); for(size_t i = 0; i < length / 2; ++i) { - d->data[i] = swap ? combine(*s, *(s + 1)) : combine(*(s + 1), *s); + ushort c; + ::memcpy(&c, s, 2); + if(swap) + c = Utils::byteSwap(c); + + d->data[i] = static_cast(c); s += 2; } }