diff options
-rw-r--r-- | SimpleIni.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/SimpleIni.h b/SimpleIni.h index 04e2b48..534e190 100644 --- a/SimpleIni.h +++ b/SimpleIni.h @@ -2836,9 +2836,15 @@ public: // the source text. return a_uInputDataLen; } - else { - return mbstowcs(NULL, a_pInputData, a_uInputDataLen); - } + +#if !defined(_WIN32) && !defined(_linux) + // fall back processing for platforms that don't support C99 usage of mbstowcs + // worst case scenario is 1:1, this should be a sufficient buffer size + return a_uInputDataLen; +#else + // get the actual required buffer size + return mbstowcs(NULL, a_pInputData, a_uInputDataLen); +#endif } /** Convert the input string from the storage format to SI_CHAR. @@ -2884,11 +2890,11 @@ public: } return retval == conversionOK; } - else { - size_t retval = mbstowcs(a_pOutputData, - a_pInputData, a_uOutputDataSize); - return retval != (size_t)(-1); - } + + // convert to wchar_t + size_t retval = mbstowcs(a_pOutputData, + a_pInputData, a_uOutputDataSize); + return retval != (size_t)(-1); } /** Calculate the number of char required by the storage format of this |