2) Allow LF->CR/LF conversion under UNICODE driver.
* Send any initial settings
*/
+ /*
+ * Get the version number first so we can check it before sending options
+ * that are now obsolete. DJP 21/06/2002
+ */
+
+ CC_lookup_pg_version(self); /* Get PostgreSQL version for
+ SQLGetInfo use */
/*
* Since these functions allocate statements, and since the connection
* is not established yet, it would violate odbc state transition
CC_send_settings(self);
CC_lookup_lo(self); /* a hack to get the oid of
our large object oid type */
- CC_lookup_pg_version(self); /* Get PostgreSQL version for
- SQLGetInfo use */
/*
* Multibyte handling is available ?
}
- /* KSQO */
- if (ci->drivers.ksqo)
+ /* KSQO (not applicable to 7.1+ - DJP 21/06/2002) */
+ if (ci->drivers.ksqo && PG_VERSION_LT(self, 7.1))
{
result = PGAPI_ExecDirect(hstmt, "set ksqo to 'ON'", SQL_NTS);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
#ifdef UNICODE_SUPPORT
if (fCType == SQL_C_WCHAR)
{
- len = utf8_to_ucs2(neut_str, -1, NULL, 0);
+ len = utf8_to_ucs2_lf(neut_str, -1, lf_conv, NULL, 0);
len *= 2;
wchanged = changed = TRUE;
}
#ifdef UNICODE_SUPPORT
if (fCType == SQL_C_WCHAR)
{
- utf8_to_ucs2(neut_str, -1, (SQLWCHAR *) pbic->ttlbuf, len / 2);
+ utf8_to_ucs2_lf(neut_str, -1, lf_conv, (SQLWCHAR *) pbic->ttlbuf, len / 2);
}
else
#endif /* UNICODE_SUPPORT */
*
* Comments: See "notice.txt" for copyright and license information.
*
- * $Id: psqlodbc.h,v 1.67 2002/06/06 04:50:47 inoue Exp $
+ * $Id: psqlodbc.h,v 1.68 2002/06/28 02:44:15 inoue Exp $
*
*/
#ifdef UNICODE_SUPPORT
UInt4 ucs2strlen(const SQLWCHAR *ucs2str);
char *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen);
-UInt4 utf8_to_ucs2(const char * utf8str, Int4 ilen, SQLWCHAR *ucs2str, UInt4 buflen);
+UInt4 utf8_to_ucs2_lf(const char * utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 buflen);
+#define utf8_to_ucs2(utf8str, ilen, ucs2str, buflen) utf8_to_ucs2_lf(utf8str, ilen, FALSE, ucs2str, buflen)
#endif /* UNICODE_SUPPORT */
/*#define _MEMORY_DEBUG_ */
#ifdef _MEMORY_DEBUG_
#define byte3_m3 0x3f
#define byte2_m1 0x1f
#define byte2_m2 0x3f
-UInt4 utf8_to_ucs2(const char *utf8str, Int4 ilen, SQLWCHAR *ucs2str, UInt4 bufcount)
+UInt4 utf8_to_ucs2_lf(const char *utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 bufcount)
{
int i;
UInt4 ocount, wcode;
{
if (iswascii(*str))
{
+ if (lfconv && *str == '\n' &&
+ (i == 0 || str[-1] != '\r'))
+ {
+ if (ocount < bufcount)
+ ucs2str[ocount] = '\r';
+ ocount++;
+ }
if (ocount < bufcount)
ucs2str[ocount] = *str;
ocount++;