From: Tsuda Kageyu Date: Tue, 12 Aug 2014 04:33:25 +0000 (+0900) Subject: Unified the same debug messages. X-Git-Tag: v1.10beta~139^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a055933e10b65ea35817ff2dddf63a9b96ee25fe;p=taglib Unified the same debug messages. --- diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 9bed6180..b311cfbb 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -52,14 +52,11 @@ namespace inline size_t UTF16toUTF8( const wchar_t *src, size_t srcLength, char *dst, size_t dstLength) { + size_t len = 0; + #ifdef _WIN32 - const int len = ::WideCharToMultiByte( - CP_UTF8, 0, src, srcLength, dst, dstLength, NULL, NULL); - if(len == 0) { - debug("String::UTF16toUTF8() - Unicode conversion error."); - } - return len; + len = ::WideCharToMultiByte(CP_UTF8, 0, src, srcLength, dst, dstLength, NULL, NULL); #else @@ -74,29 +71,25 @@ namespace ConversionResult result = ConvertUTF16toUTF8( &srcBegin, srcEnd, &dstBegin, dstEnd, lenientConversion); - if(result == conversionOK) { - return (dstBegin - reinterpret_cast(dst)); - } - else - { - debug("String::UTF16toUTF8() - Unicode conversion error."); - return 0; - } + if(result == conversionOK) + len = dstBegin - reinterpret_cast(dst); #endif + + if(len == 0) + debug("String::UTF16toUTF8() - Unicode conversion error."); + + return len; } inline size_t UTF8toUTF16( const char *src, size_t srcLength, wchar_t *dst, size_t dstLength) { + size_t len = 0; + #ifdef _WIN32 - const int len = ::MultiByteToWideChar( - CP_UTF8, 0, src, srcLength, dst, dstLength); - if(len == 0) { - debug("String::UTF8toUTF16() - Unicode conversion error."); - } - return len; + len = ::MultiByteToWideChar(CP_UTF8, 0, src, srcLength, dst, dstLength); #else @@ -111,15 +104,15 @@ namespace ConversionResult result = ConvertUTF8toUTF16( &srcBegin, srcEnd, &dstBegin, dstEnd, lenientConversion); - if(result == conversionOK) { - return (dstBegin - dst); - } - else { - debug("String::UTF8toUTF16() - Unicode conversion error."); - return 0; - } + if(result == conversionOK) + len = dstBegin - dst; #endif + + if(len == 0) + debug("String::UTF8toUTF16() - Unicode conversion error."); + + return len; } }