Mercurial > hg > orthanc-databases
changeset 331:674bbb9d1c83
added OdbcEnvironment::GlobalInitialization()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 11 Aug 2021 07:28:53 +0200 |
parents | 8f17f23c9af7 |
children | 2592c0e9b724 |
files | Framework/Odbc/OdbcEnvironment.cpp Framework/Odbc/OdbcEnvironment.h Odbc/Plugins/IndexPlugin.cpp Odbc/Plugins/StoragePlugin.cpp Odbc/UnitTests/UnitTestsMain.cpp Resources/CMake/DatabasesFrameworkConfiguration.cmake |
diffstat | 6 files changed, 27 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Odbc/OdbcEnvironment.cpp Tue Aug 10 20:52:16 2021 +0200 +++ b/Framework/Odbc/OdbcEnvironment.cpp Wed Aug 11 07:28:53 2021 +0200 @@ -94,4 +94,17 @@ } } } + + + void OdbcEnvironment::GlobalInitialization() + { + /** + * Explicitly inform the ODBC driver that the application is using + * UTF-8, by making sure that default "C" locale is used. We are + * in the scenario "ANSI application with a Unicode driver". + * https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/programming-guidelines + * https://www.progress.com/tutorials/odbc/unicode + **/ + setlocale(LC_ALL, "C"); + } }
--- a/Framework/Odbc/OdbcEnvironment.h Tue Aug 10 20:52:16 2021 +0200 +++ b/Framework/Odbc/OdbcEnvironment.h Wed Aug 11 07:28:53 2021 +0200 @@ -49,5 +49,7 @@ static std::string FormatError(SQLHANDLE handle, SQLSMALLINT type); + + static void GlobalInitialization(); }; }
--- a/Odbc/Plugins/IndexPlugin.cpp Tue Aug 10 20:52:16 2021 +0200 +++ b/Odbc/Plugins/IndexPlugin.cpp Wed Aug 11 07:28:53 2021 +0200 @@ -21,6 +21,7 @@ #include "OdbcIndex.h" +#include "../../Framework/Odbc/OdbcEnvironment.h" #include "../../Framework/Plugins/PluginInitialization.h" #include "../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" @@ -84,6 +85,8 @@ return 0; } + OrthancDatabases::OdbcEnvironment::GlobalInitialization(); + try { const std::string connectionString = odbc.GetStringValue("IndexConnectionString", "");
--- a/Odbc/Plugins/StoragePlugin.cpp Tue Aug 10 20:52:16 2021 +0200 +++ b/Odbc/Plugins/StoragePlugin.cpp Wed Aug 11 07:28:53 2021 +0200 @@ -148,6 +148,8 @@ return 0; } + OrthancDatabases::OdbcEnvironment::GlobalInitialization(); + try { const std::string connectionString = odbc.GetStringValue("StorageConnectionString", "");
--- a/Odbc/UnitTests/UnitTestsMain.cpp Tue Aug 10 20:52:16 2021 +0200 +++ b/Odbc/UnitTests/UnitTestsMain.cpp Wed Aug 11 07:28:53 2021 +0200 @@ -23,6 +23,7 @@ static std::string connectionString_; +#include "../../Framework/Odbc/OdbcEnvironment.h" #include "../../Framework/Plugins/IndexUnitTests.h" #include <Logging.h> @@ -85,6 +86,8 @@ Orthanc::Logging::EnableInfoLevel(true); //Orthanc::Logging::EnableTraceLevel(true); + OrthancDatabases::OdbcEnvironment::GlobalInitialization(); + int result = RUN_ALL_TESTS(); Orthanc::Logging::Finalize();
--- a/Resources/CMake/DatabasesFrameworkConfiguration.cmake Tue Aug 10 20:52:16 2021 +0200 +++ b/Resources/CMake/DatabasesFrameworkConfiguration.cmake Wed Aug 11 07:28:53 2021 +0200 @@ -183,7 +183,10 @@ ##################################################################### if (ENABLE_ODBC_BACKEND) - include(${CMAKE_CURRENT_LIST_DIR}/UnixOdbcConfiguration.cmake) + if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") + include(${CMAKE_CURRENT_LIST_DIR}/UnixOdbcConfiguration.cmake) + endif() + add_definitions(-DORTHANC_ENABLE_ODBC=1) list(APPEND DATABASES_SOURCES ${ORTHANC_DATABASES_ROOT}/Framework/Odbc/OdbcDatabase.cpp