toolkit/tpropertymap.cpp
toolkit/trefcounter.cpp
toolkit/tdebuglistener.cpp
- toolkit/unicode.cpp
)
+if(NOT WIN32)
+ set(unicode_SRCS
+ toolkit/unicode.cpp
+ )
+endif()
+
if(HAVE_ZLIB_SOURCE)
set(zlib_SRCS
${ZLIB_SOURCE}/adler32.c
${vorbis_SRCS} ${oggflacs_SRCS} ${mpc_SRCS} ${ape_SRCS} ${toolkit_SRCS} ${flacs_SRCS}
${wavpack_SRCS} ${speex_SRCS} ${trueaudio_SRCS} ${riff_SRCS} ${aiff_SRCS} ${wav_SRCS}
${asf_SRCS} ${mp4_SRCS} ${mod_SRCS} ${s3m_SRCS} ${it_SRCS} ${xm_SRCS} ${opus_SRCS}
+ ${unicode_SRCS} ${zlib_SRCS}
tag.cpp
tagunion.cpp
fileref.cpp
audioproperties.cpp
)
-add_library(tag ${tag_LIB_SRCS} ${zlib_SRCS} ${tag_HDRS})
+add_library(tag ${tag_LIB_SRCS} ${tag_HDRS})
if(ZLIB_FOUND)
target_link_libraries(tag ${ZLIB_LIBRARIES})
endif()
install(TARGETS tag
- FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR}
- LIBRARY DESTINATION ${LIB_INSTALL_DIR}
- RUNTIME DESTINATION ${BIN_INSTALL_DIR}
- ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
- PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/taglib
+ FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR}
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/taglib
)
-
#include <cstdio>
#include <cstring>
-#ifdef HAVE_STD_CODECVT
-# include <codecvt>
+#ifdef _WIN32
+# include <windows.h>
#else
# include "unicode.h"
#endif
namespace
{
+ using namespace TagLib;
- void UTF16toUTF8(const wchar_t *src, size_t srcLength, char *dst, size_t dstLength)
+ inline void UTF16toUTF8(
+ const wchar_t *src, size_t srcLength, char *dst, size_t dstLength)
{
-#ifdef HAVE_STD_CODECVT
+#ifdef _WIN32
- typedef std::codecvt_utf8_utf16<wchar_t> utf8_utf16_t;
-
- using namespace TagLib;
-
- const wchar_t *srcBegin = src;
- const wchar_t *srcEnd = srcBegin + srcLength;
-
- char *dstBegin = dst;
- char *dstEnd = dstBegin + dstLength;
-
- std::mbstate_t st;
- const wchar_t *source;
- char *target;
- memset(&st, 0, sizeof(st));
- std::codecvt_base::result result = utf8_utf16_t().out(
- st, srcBegin, srcEnd, source, dstBegin, dstEnd, target);
-
- if(result != utf8_utf16_t::ok) {
+ const int len = ::WideCharToMultiByte(
+ CP_UTF8, 0, src, srcLength, dst, dstLength, NULL, NULL);
+ if(len == 0) {
debug("String::UTF16toUTF8() - Unicode conversion error.");
}
#else
using namespace Unicode;
- using namespace TagLib;
- const Unicode::UTF16 *srcBegin = src;
- const Unicode::UTF16 *srcEnd = srcBegin + srcLength;
+ const UTF16 *srcBegin = src;
+ const UTF16 *srcEnd = srcBegin + srcLength;
- Unicode::UTF8 *dstBegin = reinterpret_cast<Unicode::UTF8*>(dst);
- Unicode::UTF8 *dstEnd = dstBegin + dstLength;
+ UTF8 *dstBegin = reinterpret_cast<UTF8*>(dst);
+ UTF8 *dstEnd = dstBegin + dstLength;
- Unicode::ConversionResult result = Unicode::ConvertUTF16toUTF8(
- &srcBegin, srcEnd, &dstBegin, dstEnd, Unicode::lenientConversion);
+ ConversionResult result = ConvertUTF16toUTF8(
+ &srcBegin, srcEnd, &dstBegin, dstEnd, lenientConversion);
- if(result != Unicode::conversionOK) {
+ if(result != conversionOK) {
debug("String::UTF16toUTF8() - Unicode conversion error.");
}
#endif
}
- void UTF8toUTF16(const char *src, size_t srcLength, wchar_t *dst, size_t dstLength)
+ inline void UTF8toUTF16(
+ const char *src, size_t srcLength, wchar_t *dst, size_t dstLength)
{
-#ifdef HAVE_STD_CODECVT
-
- typedef std::codecvt_utf8_utf16<wchar_t> utf8_utf16_t;
-
- using namespace TagLib;
-
- const char *srcBegin = src;
- const char *srcEnd = srcBegin + srcLength;
-
- wchar_t *dstBegin = dst;
- wchar_t *dstEnd = dstBegin + dstLength;
-
- std::mbstate_t st;
- const char *source;
- wchar_t *target;
- memset(&st, 0, sizeof(st));
- std::codecvt_base::result result = utf8_utf16_t().in(
- st, srcBegin, srcEnd, source, dstBegin, dstEnd, target);
+#ifdef _WIN32
- if(result != utf8_utf16_t::ok) {
+ const int len = ::MultiByteToWideChar(
+ CP_UTF8, 0, src, srcLength, dst, dstLength);
+ if (len == 0) {
debug("String::UTF8toUTF16() - Unicode conversion error.");
}
#else
using namespace Unicode;
- using namespace TagLib;
- const Unicode::UTF8 *srcBegin = reinterpret_cast<const Unicode::UTF8*>(src);
- const Unicode::UTF8 *srcEnd = srcBegin + srcLength;
+ const UTF8 *srcBegin = reinterpret_cast<const UTF8*>(src);
+ const UTF8 *srcEnd = srcBegin + srcLength;
- Unicode::UTF16 *dstBegin = dst;
- Unicode::UTF16 *dstEnd = dstBegin + dstLength;
+ UTF16 *dstBegin = dst;
+ UTF16 *dstEnd = dstBegin + dstLength;
- Unicode::ConversionResult result = Unicode::ConvertUTF8toUTF16(
- &srcBegin, srcEnd, &dstBegin, dstEnd, Unicode::lenientConversion);
+ ConversionResult result = ConvertUTF8toUTF16(
+ &srcBegin, srcEnd, &dstBegin, dstEnd, lenientConversion);
- if(result != Unicode::conversionOK) {
+ if(result != conversionOK) {
debug("String::UTF8toUTF16() - Unicode conversion error.");
}