diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-11-17 14:35:55 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-11-18 09:39:14 +0100 |
commit | e89ad623f4d55869f0d67cc24c28292c168e5209 (patch) | |
tree | 667542ed0b8b2d08a51a2063e47b6c8c499a1f4e /connectivity | |
parent | e36c468dab4006afcfae76b1676df7cedbb82f1d (diff) |
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@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/odbc/OTools.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/inc/odbc/OTools.hxx | 3 |
2 files changed, 3 insertions, 4 deletions
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 |