D. Richard Hipp wrote:
> On Jul 21, 2008, at 12:05 AM, C. Smith wrote:
> 
>> The collation is
>> a case-insensitive wchar compare for windows (using _wcsicmp).
> 
> The strings passed to a collating function are not zero-terminated.   
> Are you making a copy of both input strings and adding a zero  
> terminator yourself, or are you really using _wcsnicmp()?
> 
> You might want to have a look at how the "NOCASE" collation is  
> implemented in the nocaseCollatingFunc() function in the main.c source  
> file of SQLite.
> 
> D. Richard Hipp
> [EMAIL PROTECTED]
> 
> 

I didn't know the strings weren't nul terminated.  I changed my callback to:

static int _cmp(void *pCtx, int alen, const void *a,
   int blen, const void *b)
{
   int r = _wcsnicmp((const wchar_t *)a, (const wchar_t *)b,
     (alen < blen) ? alen : blen);

   if(r == 0)
     r = alen - blen;

   return r;
}

Still doesn't work though :(

sqlite> pragma encoding = 'utf16le';
sqlite> select load_extension('ext.dll');
sqlite> create table test (str collate path);
sqlite> create unique index myidx on test (str);
sqlite> insert into test values ('abc');
sqlite> select * from test where str = 'ABC';
sqlite> select * from test where str = 'abc';
sqlite> insert into test values ('abc');
sqlite> select 'abc' = 'ABC' collate path;
1
sqlite>

Still let me put two 'abc' records in and it still doesn't find any 'abc' 
records.  Yet, the collation is working if you look at the last select.

Andrew

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to