Re: Unicode/client_encoding/conversion problem

Поиск
Список
Период
Сортировка
От Andreas Pflug
Тема Re: Unicode/client_encoding/conversion problem
Дата
Msg-id 3EF06762.6010507@web.de
обсуждение исходный текст
Ответ на Re: Unicode/client_encoding/conversion problem  ("Dave Page" <dpage@vale-housing.co.uk>)
Список pgsql-odbc
Dave Page wrote:

>Thanks, committed with minor fix to close the comment in the correct
>place (pls check).
>
>
>

Hi Dave,

fix hasn't  made it correctly into the source. The comment was just to
leave the old code for reference. This probably happened because the
second fix (ResolveNumeric)  would shift the rows of the first fix.

There's no switch(param_sqltype) needed, instead all code that's under
the 3 case SQL_xxx is to be executed for unicode. Absolutely wrong is
the last line "buf=buffer" in the default hieve, because this would
override the previous conversion.

Attached a new patch file, diff'd from the current cvs.

Regards,
Andreas
RCS file: /usr/local/cvsroot/psqlodbc/psqlodbc/convert.c,v
retrieving revision 1.102
diff -r1.102 convert.c
2561,2565d2560
< /*********************
<  * it's not correct to convert depending on param_sqltype,
<  * because the client_encoding is always unicode.
<  * We need conversion in any case.
< */
2569,2594c2564,2571
<             switch (param_sqltype)
<             {
<                 case SQL_WCHAR:
<                 case SQL_WVARCHAR:
<                 case SQL_WLONGVARCHAR:
<                     if (SQL_NTS == used)
<                         used = strlen(buffer);
<                     allocbuf = malloc(2 * (used + 1));
<                     used = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buffer,
<                         used, (LPWSTR) allocbuf, used + 1);
<                     buf = ucs2_to_utf8((SQLWCHAR *) allocbuf, used, &used);
<                     free(allocbuf);
<                     allocbuf = buf;
<                     break;
<                 default:
<
<                         if (SQL_NTS == used)
<                         used = strlen(buffer);
<                     allocbuf = malloc(2 * (used + 1));
<                     used = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buffer,
<                         used, (LPWSTR) allocbuf, used + 1);
<                     buf = ucs2_to_utf8((SQLWCHAR *) allocbuf, used, &used);
<                     free(allocbuf);
<                     allocbuf = buf;
<                     buf = buffer;
<             }
---
>             if (SQL_NTS == used)
>                 used = strlen(buffer);
>             allocbuf = malloc(2 * (used + 1));
>             used = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buffer,
>                 used, (LPWSTR) allocbuf, used + 1);
>             buf = ucs2_to_utf8((SQLWCHAR *) allocbuf, used, &used);
>             free(allocbuf);
>             allocbuf = buf;


В списке pgsql-odbc по дате отправления:

Предыдущее
От: "Dave Page"
Дата:
Сообщение: Re: ResolveNumericParam problem
Следующее
От: "Dave Page"
Дата:
Сообщение: Re: Unicode/client_encoding/conversion problem