From: Gilles DAVID Date: Thu, 1 Jun 2017 09:29:44 +0000 (+0200) Subject: Python 3 - Use size of wchar_t X-Git-Tag: V9_0_0~24^2~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b4d688737db92eb197979d4f725ce26b5a931fda;p=modules%2Fkernel.git Python 3 - Use size of wchar_t --- diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 3826e4f69..58c7c5ea1 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #ifdef WIN32 #include @@ -166,14 +167,13 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const wchar_t* aWUrl) Unexpect aCatch(SalomeException); - // Converts UTF8 url to encoded version + // Converts unicode url to encoded version setlocale(LC_ALL, ""); - char aUrl[256]; - int ret; - memset( aUrl, 0, 256); - ret = wcstombs(aUrl, aWUrl, 255); - if (ret==256) aUrl[255]='\0'; - MESSAGE("Begin of SALOMEDS_StudyManager_i::Open " << aUrl); + size_t urlLen = std::wcslen(aWUrl); + char aUrl[urlLen+1]; + memset( aUrl, 0, urlLen+1); + wcstombs(aUrl, aWUrl, sizeof(aUrl)); + MESSAGE("Begin of SALOMEDS_StudyManager_i::Open " << aUrl << " (" << urlLen << ")"); #ifndef ALLOW_MULTI_STUDIES