Re: [sqlite] UTF-8 and ISO-8859-1 in the same library

2004-07-30 Thread Christian Smith
On Fri, 30 Jul 2004, Bertrand Mansion wrote:

>Hi,
>
>How difficult would it be to have both UTF-8 and ISO-8859-1 supported in
>the same library (2.8.15) ? By looking quickly at the sources, it seems
>to be just a matter of changing the functions likeFunc(), globFunc(),
>lengthFunc() and substrFunc(). They could use a flag in order to call the
>code required by the specified encoding.


The problem is that the encoding isn't stored with the data, hence the
library must be configured to assume one or the other.

As the two are mutually incompatible, you're probably better off with
UTF-8 encoding and converting strings yourself. I always compile SQLite v2
with UTF-8 encoding, as all the characters in ISO-8859-1 can be
represented in UTF-8 (I believe. i18n is not my area of expertise.)


>
>In my case, this is needed as I can't figure out in advance which version
>of the library the user wants to use. But my application lets the user
>specify in which encodings the inputs are.


Why not compile and bundle SQLite with your application? You have full
control then.


>
>Is this the way to go or am I missing something ?
>
>Thanks in advance,
>
>Bertrand Mansion
>Mamasam
>

-- 
/"\
\ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
 X   - AGAINST MS ATTACHMENTS
/ \


[sqlite] HOWTO: Adding Natural Sort To Sqlite Database...

2004-07-30 Thread tezozomoc


HOWTO: Adding Natural Sort To Sqlite Database...

Assumption... this is based on SQLITE 2.8.6... forgive the aging..


I will make this very short and sweet... 

1.  Get the following two files:

a.. strnatcmp.c, strnatcmp.h - the algorithm itself from 
a.. 
http://sourcefrog.net/projects/natsort/

add to your sqlite build project, I am using VxWorks, so the way that I did it will 
probably will not make sense...

2.  Open util.c

3.  Replace the following: 
  **
  ** $Id: util.c,v 1.66 2003/07/30 12:34:12 drh Exp $
  */
  #include "sqliteInt.h"
  #include 
  #include 

 with 

  ** $Id: util.c,v 1.66 2003/07/30 12:34:12 drh Exp $
  */
  #include "sqliteInt.h"
  #include 
  #include 
  #include "strnatcmp.h"

4.  Find the following function sqliteSortCompare(...)

Replace

  assert( a[0]==b[0] );
  if( (dir=a[0])=='A' || a[0]=='D' ){
   /*-->*/res = strcmp([1],[1]);
if( res ) break;
  }else{
isNumA = sqliteIsNumber([1]);
isNumB = sqliteIsNumber([1]);
if( isNumA ){
  double rA, rB;
  if( !isNumB ){
res = -1;
break;
  }
  rA = atof([1]);
  rB = atof([1]);
  if( rArB ){
res = +1;
break;
  }
}else if( isNumB ){
  res = +1;
  break;
}else{
/*-->*/res = strcmp([1],[1]);
  if( res ) break;
}
  }

with 

  assert( a[0]==b[0] );
  if( (dir=a[0])=='A' || a[0]=='D' ){
/*res = strcmp([1],[1]);*/
res = strnatcmp([1],[1]);
if( res ) break;
  }else{
isNumA = sqliteIsNumber([1]);
isNumB = sqliteIsNumber([1]);
if( isNumA ){
  double rA, rB;
  if( !isNumB ){
res = -1;
break;
  }
  rA = atof([1]);
  rB = atof([1]);
  if( rArB ){
res = +1;
break;
  }
}else if( isNumB ){
  res = +1;
  break;
}else{
/*res = strcmp([1],[1]);*/
res = strnatcmp([1],[1]);
  if( res ) break;
}
  }

This has made my SQLITE experience much better... no need for COLLATE Function .

by
Tezozomoc.


Re: [sqlite] Versions 2.8.15 and 3.0.3 available

2004-07-30 Thread sankara . narayanan

Return Receipt
   
Your  Re: [sqlite] Versions 2.8.15 and 3.0.3 available 
document   
:  
   
was   Sankara Narayanan/BTC/PIN/PHILIPS
received   
by:
   
at:   30/07/2004 12:51:05 ZE5B 
   






RE: [sqlite] Wildcards in LIKE

2004-07-30 Thread Dennis Volodomanov
Ok, just found it - sorry...

But this does raise a question, I have UNICODE data, but it says that
LIKE only works correctly (i.e. case-insensitive) on 7-bit data. Can
someone tell me please how to make it work correctly for UNICODE as well
then?

As I read from the docs there, I have to override the like(x,y)
function, but I don't really know how, so any help here is appreciated
:-)

Thanks!

   Dennis

//
Software for animal shelters
http://www.smartpethealth.com
//
-Original Message-
From: Dennis Volodomanov 
Sent: Friday, July 30, 2004 3:47 PM
To: [EMAIL PROTECTED]
Subject: [sqlite] Wildcards in LIKE

Hello,

Does SQLite v3 support wildcards in the LIKE statement and if yes, how
do I express them? (sorry didn't find any info in the docs on this)

TIA

   Dennis

//
Software for animal shelters
http://www.smartpethealth.com
//