Kaydet (Commit) e89ad623 authored tarafından Mike Kaganski's avatar Mike Kaganski

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/44877Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst e36c468d
...@@ -306,8 +306,7 @@ void OTools::ThrowException(const OConnection* _pConnection, ...@@ -306,8 +306,7 @@ void OTools::ThrowException(const OConnection* _pConnection,
const SQLHANDLE _pContext, const SQLHANDLE _pContext,
const SQLSMALLINT _nHandleType, const SQLSMALLINT _nHandleType,
const Reference< XInterface >& _xInterface, const Reference< XInterface >& _xInterface,
const bool _bNoFound, const bool _bNoFound)
const rtl_TextEncoding _nTextEncoding)
{ {
switch(_rRetCode) switch(_rRetCode)
{ {
...@@ -350,6 +349,7 @@ void OTools::ThrowException(const OConnection* _pConnection, ...@@ -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_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"); 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 // For the Return Code of SQLError see ODBC 2.0 Programmer's Reference Page 287ff
throw SQLException( OUString(reinterpret_cast<char *>(szErrorMessage), pcbErrorMsg, _nTextEncoding), throw SQLException( OUString(reinterpret_cast<char *>(szErrorMessage), pcbErrorMsg, _nTextEncoding),
_xInterface, _xInterface,
......
...@@ -105,8 +105,7 @@ namespace connectivity ...@@ -105,8 +105,7 @@ namespace connectivity
SQLHANDLE _pContext, SQLHANDLE _pContext,
SQLSMALLINT _nHandleType, SQLSMALLINT _nHandleType,
const css::uno::Reference< css::uno::XInterface >& _xInterface, const css::uno::Reference< css::uno::XInterface >& _xInterface,
bool _bNoFound=true, bool _bNoFound=true);
rtl_TextEncoding _nTextEncoding = RTL_TEXTENCODING_MS_1252);
/// @throws css::sdbc::SQLException /// @throws css::sdbc::SQLException
/// @throws css::uno::RuntimeException /// @throws css::uno::RuntimeException
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment