From: Gilles DAVID Date: Tue, 6 Jun 2017 12:02:38 +0000 (+0200) Subject: Porting Python3: Use of encode/decode functions X-Git-Tag: V9_0_0~24^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ebb6ef6ae3bc533475ce5188e7734a02017e3a4b;p=modules%2Fkernel.git Porting Python3: Use of encode/decode functions --- diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index d8a537c95..9a1f7a16e 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -503,18 +503,8 @@ std::string SALOMEDS_Study::URL() SALOMEDS::Locker lock; aURL = _local_impl->URL(); } - else { - wchar_t* wurl = _corba_impl->URL(); - - // Converts unicode url to encoded version - setlocale(LC_ALL, ""); - size_t urlLen = std::wcslen(wurl); - char url[urlLen+1]; - memset( url, 0, urlLen+1); - wcstombs(url, wurl, sizeof(url)); - - aURL = std::string(url); - } + else + aURL = Kernel_Utils::encode_s(_corba_impl->URL()); return aURL; } @@ -524,15 +514,7 @@ void SALOMEDS_Study::URL(const std::string& url) SALOMEDS::Locker lock; _local_impl->URL(url); } - else { - setlocale(LC_ALL, ""); - size_t urlLen = url.size(); - wchar_t wurl[urlLen+1]; - memset( wurl, 0, urlLen+1); - mbstowcs(wurl, url.c_str(), sizeof(wurl)); - - _corba_impl->URL(wurl); - } + else _corba_impl->URL(Kernel_Utils::decode_s(url)); } int SALOMEDS_Study::StudyId() diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 3de6dbcce..987c98fa3 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -167,12 +167,8 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const wchar_t* aWUrl) Unexpect aCatch(SalomeException); - // Converts unicode url to encoded version - setlocale(LC_ALL, ""); - size_t urlLen = std::wcslen(aWUrl); - char aUrl[urlLen+1]; - memset( aUrl, 0, urlLen+1); - wcstombs(aUrl, aWUrl, sizeof(aUrl)); + std::string aUrl = Kernel_Utils::encode_s(aWUrl); + MESSAGE("Begin of SALOMEDS_StudyManager_i::Open " << aUrl << " (" << urlLen << ")"); @@ -187,10 +183,10 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const wchar_t* aWUrl) } #endif // ;ALLOW_MULTI_STUDIES - SALOMEDSImpl_Study* aStudyImpl = _impl->Open(std::string(aUrl)); + SALOMEDSImpl_Study* aStudyImpl = _impl->Open(aUrl); if ( !aStudyImpl ) { - std::string errmsg = "Impossible to Open study from file " + std::string(aUrl); + std::string errmsg = "Impossible to Open study from file " + aUrl; THROW_SALOME_CORBA_EXCEPTION(errmsg.c_str(), SALOME::BAD_PARAM) } @@ -295,7 +291,7 @@ CORBA::Boolean SALOMEDS_StudyManager_i::SaveAs(const wchar_t* aWUrl, SALOMEDS::S } SALOMEDSImpl_Study* aStudyImpl = _impl->GetStudyByID(aStudy->StudyId()); - return _impl->SaveAs(std::string(Kernel_Utils::encode(aWUrl)), aStudyImpl, _factory, theMultiFile); + return _impl->SaveAs(Kernel_Utils::encode_s(aWUrl), aStudyImpl, _factory, theMultiFile); } CORBA::Boolean SALOMEDS_StudyManager_i::SaveAsASCII(const wchar_t* aWUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) @@ -308,7 +304,7 @@ CORBA::Boolean SALOMEDS_StudyManager_i::SaveAsASCII(const wchar_t* aWUrl, SALOME } SALOMEDSImpl_Study* aStudyImpl = _impl->GetStudyByID(aStudy->StudyId()); - return _impl->SaveAsASCII(std::string(Kernel_Utils::encode(aWUrl)), aStudyImpl, _factory, theMultiFile); + return _impl->SaveAsASCII(Kernel_Utils::encode_s(aWUrl), aStudyImpl, _factory, theMultiFile); } //============================================================================ @@ -334,7 +330,6 @@ SALOMEDS::ListOfOpenStudies* SALOMEDS_StudyManager_i::GetOpenStudies() { for (unsigned int ind=0; ind < aLength; ind++) { - SCRUTE(anOpened[ind]->Name()) ; _list_open_studies[ind] = CORBA::wstring_dup(Kernel_Utils::decode_s(anOpened[ind]->Name())); SCRUTE(Kernel_Utils::encode(_list_open_studies[ind])) ; }