From 4bcb2f56e92b7eab9f660cb78e8a52121194b0ff Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 19 Jan 2018 15:59:54 +0300 Subject: [PATCH] Implement unicode support in SALOME: first attempt --- src/SalomeApp/SalomeApp_Application.cxx | 8 ++++---- tools/PyConsole/src/PyConsole_Request.cxx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 462f1a389..eb93a7be7 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -272,7 +272,7 @@ void SalomeApp_Application::start() script.remove( QRegExp("^python.*[\\s]+") ); QString cmd = script+" "+args; - QString command = QString( "exec(open(\"%1\").read())" ).arg(cmd.trimmed()); + QString command = QString( "exec(open(\"%1\",encoding='utf-8').read())" ).arg(cmd.trimmed()); pyConsole->exec(command); } } // end for loop on pyfiles QStringList @@ -497,7 +497,7 @@ void SalomeApp_Application::onNewWithScript() { onNewDoc(); - QString command = QString("exec(open(\"%1\").read())").arg(aFile); + QString command = QString("exec(open(\"%1\",encoding='utf-8').read())").arg(aFile); #ifndef DISABLE_PYCONSOLE PyConsole_Console* pyConsole = pythonConsole(); @@ -924,7 +924,7 @@ void SalomeApp_Application::onLoadScript( ) if ( !aFile.isEmpty() ) { - QString command = QString("exec(open(\"%1\").read())").arg(aFile); + QString command = QString("exec(open(\"%1\",encoding='utf-8').read())").arg(aFile); #ifndef DISABLE_PYCONSOLE PyConsole_Console* pyConsole = pythonConsole(); @@ -1958,7 +1958,7 @@ bool SalomeApp_Application::onRestoreStudy( const QString& theDumpScript, SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); // load study from the temporary directory - QString command = QString( "exec(open(\"%1\").read())" ).arg( theDumpScript ); + QString command = QString( "exec(open(\"%1\",encoding='utf-8').read())" ).arg( theDumpScript ); #ifndef DISABLE_PYCONSOLE PyConsole_Console* pyConsole = app->pythonConsole(); diff --git a/tools/PyConsole/src/PyConsole_Request.cxx b/tools/PyConsole/src/PyConsole_Request.cxx index aa41c259e..690d3dbbd 100644 --- a/tools/PyConsole/src/PyConsole_Request.cxx +++ b/tools/PyConsole/src/PyConsole_Request.cxx @@ -56,7 +56,7 @@ PyConsole_ExecCommand::PyConsole_ExecCommand( PyInterp_Interp* theInterp, void PyConsole_ExecCommand::execute() { if ( myCommand != "" ) { - int ret = getInterp()->run( myCommand.toLatin1().data() ); + int ret = getInterp()->run( myCommand.toUtf8().data() ); if ( ret < 0 ) myState = PyInterp_Event::ES_ERROR; else if ( ret > 0 ) -- 2.39.2