ODBC Driver 7.02.0001 (Win32) (Unicode mode): CRLF->LF works, LF->CRLF doesn't

From: "Julian Mehnle, Linksystem Muenchen" <j(dot)mehnle(at)buero(dot)link-m(dot)de>
To: pgsql-hackers(at)postgresql(dot)org, pgsql-odbc(at)postgresql(dot)org
Subject: ODBC Driver 7.02.0001 (Win32) (Unicode mode): CRLF->LF works, LF->CRLF doesn't
Date: 2002-06-21 14:56:11
Message-ID: aeveq3$see$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-odbc

Hi all!

Recently I tried to use the new 7.02.0001 Win32 ODBC driver in the new
(beta) Unicode mode in conjunction with MS Access 2000 and a "UNICODE"
encoded database stored in a PostgreSQL 7.2.1 database running on a
Linux system.

I noticed that when the "LF<->CRLF Conversion" option is *enabled* in
the driver's settings dialog, only a CRLF->LF conversion (while writing
to the database) is performed, but no LF->CRLF conversion (while reading
from the database)!

I thought that this might be a bug, and thus downloaded a local copy of
the ODBC driver sources from CVS. I searched a bit and AFAICT found the
reason for the ill behavior, so I made a patch.

Julian.

==================8<==================snip==================
--- convert.c Fri Jun 21 15:48:43 2002
+++ convert.c.new Fri Jun 21 16:50:01 2002
@@ -699,12 +699,20 @@
if (pbic->data_left < 0)
{
BOOL lf_conv =
SC_get_conn(stmt)->connInfo.lf_conversion;
+ int lf_converted_len;
#ifdef UNICODE_SUPPORT
if (fCType == SQL_C_WCHAR)
{
- len =
utf8_to_ucs2(neut_str, -1, NULL, 0);
+ char* temp_str;
+
+ /* convert linefeeds to
carriage-return/linefeed */
+ lf_converted_len =
convert_linefeeds(neut_str, NULL, 0, lf_conv, &changed);
+ temp_str =
malloc(lf_converted_len + 1);
+ convert_linefeeds(neut_str,
temp_str, lf_converted_len + 1, lf_conv, &changed);
+ len =
utf8_to_ucs2(temp_str, -1, NULL, 0);
len *= 2;
wchanged = changed = TRUE;
+ free(temp_str);
}
else
#endif /* UNICODE_SUPPORT */
@@ -728,7 +736,12 @@
#ifdef UNICODE_SUPPORT
if (fCType == SQL_C_WCHAR)
{
-
utf8_to_ucs2(neut_str, -1, (SQLWCHAR *) pbic->ttlbuf, len / 2);
+ char* temp_str;
+
+ temp_str =
malloc(lf_converted_len + 1);
+
convert_linefeeds(neut_str, temp_str, lf_converted_len + 1, lf_conv,
&changed);
+
utf8_to_ucs2(temp_str, -1, (SQLWCHAR *) pbic->ttlbuf, len / 2);
+ free(temp_str);
}
else
#endif /* UNICODE_SUPPORT */

==================snip==================>8==================

--
Linksystem Muenchen GmbH info(at)link-m(dot)de
Schloerstrasse 10 http://www.link-m.de
80634 Muenchen Tel. 089 / 890 518-0
We make the Net work. Fax 089 / 890 518-77

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2002-06-21 14:56:51 Re: ADTs and embedded sql
Previous Message Michael Meskes 2002-06-21 14:54:12 Re: ecpg and bison again

Browse pgsql-odbc by date

  From Date Subject
Next Message Julian Mehnle, Linksystem Muenchen 2002-06-21 15:24:56 Re: ODBC Driver 7.02.0001 (Win32) (Unicode mode): CRLF->LF works, LF->CRLF doesn't
Previous Message anks 2002-06-21 11:21:46