[Libreoffice-commits] core.git: connectivity/source

Mike Kaganski mike.kaganski at collabora.com
Sat Nov 18 08:39:37 UTC 2017


 connectivity/source/drivers/odbc/OTools.cxx |    4 ++--
 connectivity/source/inc/odbc/OTools.hxx     |    3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

New commits:
commit e89ad623f4d55869f0d67cc24c28292c168e5209
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Fri Nov 17 14:35:55 2017 +0200

    Assume thread encoding for ODBC status string
    
    OTools::ThrowException uses SQLGetDiagRec to get error message. It's not
    the caller's responsibility to define the encoding of resulting string.
    Also, using the default setting of RTL_TEXTENCODING_MS_1252 turns
    returned localized strings into garbage.
    
    To allow correct conversion into Unicode string, let's use current
    thread encoding, and drop the input encoding parameter.
    
    Change-Id: Idb02e3ebb4fc407ce5e658fb2137ea2aa3bc127d
    Reviewed-on: https://gerrit.libreoffice.org/44877
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/connectivity/source/drivers/odbc/OTools.cxx b/connectivity/source/drivers/odbc/OTools.cxx
index 5424ef8cc756..f7a222e12860 100644
--- a/connectivity/source/drivers/odbc/OTools.cxx
+++ b/connectivity/source/drivers/odbc/OTools.cxx
@@ -306,8 +306,7 @@ void OTools::ThrowException(const OConnection* _pConnection,
                             const SQLHANDLE _pContext,
                             const SQLSMALLINT _nHandleType,
                             const Reference< XInterface >& _xInterface,
-                            const bool _bNoFound,
-                            const rtl_TextEncoding _nTextEncoding)
+                            const bool _bNoFound)
 {
     switch(_rRetCode)
     {
@@ -350,6 +349,7 @@ void OTools::ThrowException(const OConnection* _pConnection,
     OSL_ENSURE(n != SQL_INVALID_HANDLE,"SdbODBC3_SetStatus: SQLError returned SQL_INVALID_HANDLE");
     OSL_ENSURE(n == SQL_SUCCESS || n == SQL_SUCCESS_WITH_INFO || n == SQL_NO_DATA_FOUND || n == SQL_ERROR,"SdbODBC3_SetStatus: SQLError failed");
 
+    rtl_TextEncoding _nTextEncoding = osl_getThreadTextEncoding();
     // For the Return Code of SQLError see ODBC 2.0 Programmer's Reference Page 287ff
     throw SQLException( OUString(reinterpret_cast<char *>(szErrorMessage), pcbErrorMsg, _nTextEncoding),
                                     _xInterface,
diff --git a/connectivity/source/inc/odbc/OTools.hxx b/connectivity/source/inc/odbc/OTools.hxx
index 29b83c7ec8fe..377a42de0ada 100644
--- a/connectivity/source/inc/odbc/OTools.hxx
+++ b/connectivity/source/inc/odbc/OTools.hxx
@@ -105,8 +105,7 @@ namespace connectivity
                                         SQLHANDLE _pContext,
                                         SQLSMALLINT _nHandleType,
                                         const css::uno::Reference< css::uno::XInterface >& _xInterface,
-                                        bool _bNoFound=true,
-                                        rtl_TextEncoding _nTextEncoding = RTL_TEXTENCODING_MS_1252);
+                                        bool _bNoFound=true);
 
             /// @throws css::sdbc::SQLException
             /// @throws css::uno::RuntimeException


More information about the Libreoffice-commits mailing list