]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Porting Python3: Use of encode/decode functions
authorGilles DAVID <gilles-g.david@edf.fr>
Tue, 6 Jun 2017 12:02:38 +0000 (14:02 +0200)
committerGilles DAVID <gilles-g.david@edf.fr>
Tue, 6 Jun 2017 12:02:38 +0000 (14:02 +0200)
src/SALOMEDS/SALOMEDS_Study.cxx
src/SALOMEDS/SALOMEDS_StudyManager_i.cxx

index d8a537c9584fcfeb161d8326defd4a826c8174af..9a1f7a16e3ae67e516cd38387d921e231addee82 100644 (file)
@@ -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()
index 3de6dbccedeb92ff74245e081e06fcc4d1781fa2..987c98fa3dc1524d5daf856bfbb7568498a70d45 100644 (file)
@@ -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])) ;
         }