Skip to Content.
Sympa Menu

freetds - Re: [freetds] CTLib patch

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] CTLib patch
  • Date: Thu, 18 Jun 2009 13:23:41 +0200

2009/6/17 Andrew Victor <avictor.za AT gmail.com>
>
> hi Frediano,
>
> > ... it seems that client datatype does not support
> > wide characters, isn't it? So you are correctly trying to bind client
> > utf-8 (multi-byte) to server wide characters (nvarchar in mssql),
> > isn't it?
>
> There must be some data-type mapping to NVARCHAR?  I assumed it was
> CS_UNICHAR_TYPE.
>

Well... I think you should be able to map even with CS_CHAR_TYPE and
if you set client encoding to utf-8 you should be able to use utf-8.

>
> > Do you have an example so I can write a small unittests??
>
> I have extended the FreeTDS ctlib unit-test "rpc_ct_param.c", which is
> attached.
> Just ensure you have "client charset = UTF-8" in you freetds.conf

I'm merging your test. Code should work with either mssql and sybase
testing for unichar or nvarchar (I already wrote some code).

>
> Without the patch the unit-test gives:
>
> Open Client Message:
> Message number: LAYER = (0) ORIGIN = (0) SEVERITY = (9) NUMBER = (98)
> Message String: Error converting characters into server's character
> set. Some character(s) could not be converted
>
> Server message:
> Message number: 8016, Severity 16, State 26, Line 1
> Server 'xxxx'
> Message String: The incoming tabular data stream (TDS) remote
> procedure call (RPC) protocol stream is incorrect. Parameter 2
> ("@nvparam"): Data type 0xA7 has an invalid data length or metadata
> length.
>

Quite strange... I didn't get such error...

>
> > So you bind @email with datafmt->datatype == CS_UNICHAR_TYPE, isn't it ??
>
> Yes.
> I assumed:
>   CS_CHAR_TYPE = varchar = CP1252 ASCII
>   CS_UNICHAR_TYPE = nvarchar = UTF8

I looked at ctlib samples and not, CS_UNICHAR_TYPE means utf-16
(similar to ucs-2) so I'm updating the test to reflect this encoding.

>
> > Probably the second :) Well... a bug or a missing feature :)
> > CS_UNIVARCHAR_TYPE isn't better ??
>
> I see no CS_UNIVARCHAR_TYPE defined...


I found some documentation for CS_UNIVARCHAR_TYPE but I have to admit
that is not defined in Sybase headers.

>
> Regards,
>  Andrew Victor

bye
  freddy77




Archive powered by MHonArc 2.6.24.

Top of Page