From 518a165d51be822ae34c89146cd6a0d75e41852b Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Sat, 26 Apr 2025 12:33:23 +1000 Subject: [PATCH] odbc32: SQLDriverConnectW fallback to SQLDriverConnect when required. --- dlls/odbc32/proxyodbc.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index cf9d72e8452..e26fdcb8620 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -6861,11 +6861,44 @@ static SQLRETURN driver_connect_win32_w( struct connection *con, SQLHWND window, SQLSMALLINT len, SQLWCHAR *out_conn_str, SQLSMALLINT buflen, SQLSMALLINT *len2, SQLUSMALLINT completion ) { + SQLRETURN ret = SQL_ERROR; + if (con->hdr.win32_funcs->SQLDriverConnectW) return con->hdr.win32_funcs->SQLDriverConnectW( con->hdr.win32_handle, window, in_conn_str, len, out_conn_str, buflen, len2, completion ); - if (con->hdr.win32_funcs->SQLDriverConnect) FIXME( "Unicode to ANSI conversion not handled\n" ); - return SQL_ERROR; + if (con->hdr.win32_funcs->SQLDriverConnect) + { + SQLCHAR *in = NULL, *out = NULL; + SQLSMALLINT in_len = 0, out_len = 0; + + in_len = WideCharToMultiByte(CP_ACP, 0, in_conn_str, len, NULL, 0, NULL, NULL); + if (!(in = malloc(in_len + 1))) return SQL_ERROR; + + WideCharToMultiByte(CP_ACP, 0, in_conn_str, len, (char *)in, in_len, NULL, NULL); + in[in_len] = 0; + + if (out_conn_str && buflen > 0) + { + if (!(out = malloc(buflen))) + { + free(in); + return SQL_ERROR; + } + } + + ret = con->hdr.win32_funcs->SQLDriverConnect( con->hdr.win32_handle, window, in, in_len, out, buflen, &out_len, completion ); + + if (SQL_SUCCEEDED(ret) && out_conn_str && out) + { + MultiByteToWideChar(CP_ACP, 0, (char *)out, out_len, out_conn_str, buflen); + if (len2) *len2 = out_len; + } + + free(in); + free(out); + } + + return ret; } static SQLRETURN driver_connect_unix_w( struct connection *con, SQLHWND window, SQLWCHAR *in_conn_str, SQLSMALLINT len, -- 2.47.2