From 64b04c94130295e9e7cf75317ede25bbbb274346 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Tue, 2 Aug 2005 12:52:03 +0000 Subject: [PATCH] Fix unicode copy & convert bug. SQLGetData with SQL_C_WCHAR now returns SQL_SUCCESS once the whole string is sent, and doesn't lose odd characters like it did. --- convert.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/convert.c b/convert.c index 23a7943..2fc68e8 100644 --- a/convert.c +++ b/convert.c @@ -944,19 +944,23 @@ inolog("2stime fr=%d\n", std_time.fr); if (SQL_C_WCHAR == fCType && ! wchanged) { - if (cbValueMax > (SDWORD) (WCLEN * len)) + if (cbValueMax > (SDWORD) (WCLEN * (len + 1))) { char *str = strdup(rgbValueBindRow); UInt4 ucount = utf8_to_ucs2(str, len, (SQLWCHAR *) rgbValueBindRow, cbValueMax / WCLEN); if (cbValueMax < (SDWORD) (WCLEN * ucount)) result = COPY_RESULT_TRUNCATED; - len = ucount * WCLEN; + // len = ucount * WCLEN; free(str); } else { - len *= WCLEN; - result = COPY_RESULT_TRUNCATED; + if ((SDWORD) (len + WCLEN) <= cbValueMax) + { + result = COPY_OK; + } + else + result = COPY_RESULT_TRUNCATED; } } -- 2.39.5