Re: [sqlite] UTF16 Encoding

2007-02-28 Thread Nuno Lucas

On 2/28/07, Pavan <[EMAIL PROTECTED]> wrote:

>But I'm thinking you really want to do this anyway:

Well, I have a requirement to store/retrieve UTF16 strings.  The current
discussion thread
is based on that.  Pls let me know if my understanding of using
sqlite3_open16 is correct
to store and retrieve utf16 strings.


A sqlite database stores text as UTF-8 text, by default, meaning you
can use any sqlite UTF-16 function to retrieve and/or store UNICODE
data, even on a database no open using sqlite3_open16().

The only difference is that if you use sqlite3_open16 to create a new
database, internally the database will store text as UTF-16, instead
of UTF-8, but to the user, the result will be exactly the same.

As Dan pointed out, creating a database using sqlite3_open16() is
exactly the same as using sqlite3_open() followed by executing
"PRAGMA encoding=UTF-16", but all functions, having or not the "16"
suffix will return exactly the same data, though with different
encodings.

If you need to get UTF-16 strings, you have 2 options: either use the
UTF-8 sqlite functions and latter convert to UTF-16 or use the UTF-16
functions, but the data in the database is the same.

It depends on your application what makes more sense to you. On Linix,
UTF-8 makes more sense than UTF-16 because wchar_t can't be used to
store UTF-16 strings, while on windows, you can just use wchar_t
strings and call the UTF-16 functions.

You decide what it's better...

Regards,
~Nuno Lucas

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] UTF16 Encoding

2007-02-28 Thread Pavan

But I'm thinking you really want to do this anyway:


Well, I have a requirement to store/retrieve UTF16 strings.  The current
discussion thread
is based on that.  Pls let me know if my understanding of using
sqlite3_open16 is correct
to store and retrieve utf16 strings.

Thanks,
Pavan.



On 2/28/07, Dan Kennedy <[EMAIL PROTECTED]> wrote:


On Wed, 2007-02-28 at 13:13 +0100, Pavan wrote:
> Hi Lucas,
>
> >Shouldn't it be "sqlite3_open16(L"test.db",)" ?
>
> I tried this call. It works. But, the db file is created only with the
first
> character name
> and the extenstion is also missing. (its like 't')
>
> Also, can you point to me at some documentation which explains what does
> the 'L' mean in the API ?

It means "string literal", and is used for building an array of wchar_t
elements (instead of regular 8-bit char). The thing is, C doesn't
say how big wchar_t is supposed to be. Some compilers make it 32-bit
(yours could be one of these), and others make it 16-bit. There
is, AFAIK, no portable way to declare UTF-16 string constants using C.

Please inform me if I'm wrong about that, it's something I'd like to
know how to do :)

But I'm thinking you really want to do this anyway:

sqlite3_open("test.db", );
sqlite3_exec(db, "PRAGMA encoding = UTF-16", 0, 0, 0);

sqlite3_open16() just converts the argument back to UTF-8 and does
exactly the above anyway.

Dan.


> Thanks,
> Pavan.
>
>
> On 2/28/07, Nuno Lucas <[EMAIL PROTECTED]> wrote:
> >
> > On 2/28/07, Pavan <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > >
> > > When i tried to create the db file using API sqlite3_open16("test.db
> > ",)
> > > it creats the file name with some junk
> > > characters.
> >
> > Shouldn't it be "sqlite3_open16(L"test.db",)" ?
> >
> > Regards,
> > ~Nuno Lucas
> >
> > > The file name is correct if i use sqlite3_open("test.db",).  Does
it
> > mean
> > > sqlite3 does not support
> > > UTF16 encoding ?
> > > or
> > > Am i missing some package ?
> > >
> > > Thanks,
> > > Pavan.
> >
> >
> >
-
> > To unsubscribe, send email to [EMAIL PROTECTED]
> >
> >
-
> >
> >
>
>



-
To unsubscribe, send email to [EMAIL PROTECTED]

-





--
'
Always finish stronger than you start
*


Re: [sqlite] UTF16 Encoding

2007-02-28 Thread Dan Kennedy
On Wed, 2007-02-28 at 13:13 +0100, Pavan wrote:
> Hi Lucas,
> 
> >Shouldn't it be "sqlite3_open16(L"test.db",)" ?
> 
> I tried this call. It works. But, the db file is created only with the first
> character name
> and the extenstion is also missing. (its like 't')
> 
> Also, can you point to me at some documentation which explains what does
> the 'L' mean in the API ?

It means "string literal", and is used for building an array of wchar_t
elements (instead of regular 8-bit char). The thing is, C doesn't
say how big wchar_t is supposed to be. Some compilers make it 32-bit
(yours could be one of these), and others make it 16-bit. There
is, AFAIK, no portable way to declare UTF-16 string constants using C.

Please inform me if I'm wrong about that, it's something I'd like to 
know how to do :)

But I'm thinking you really want to do this anyway:

sqlite3_open("test.db", );
sqlite3_exec(db, "PRAGMA encoding = UTF-16", 0, 0, 0);

sqlite3_open16() just converts the argument back to UTF-8 and does
exactly the above anyway.

Dan.


> Thanks,
> Pavan.
> 
> 
> On 2/28/07, Nuno Lucas <[EMAIL PROTECTED]> wrote:
> >
> > On 2/28/07, Pavan <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > >
> > > When i tried to create the db file using API sqlite3_open16("test.db
> > ",)
> > > it creats the file name with some junk
> > > characters.
> >
> > Shouldn't it be "sqlite3_open16(L"test.db",)" ?
> >
> > Regards,
> > ~Nuno Lucas
> >
> > > The file name is correct if i use sqlite3_open("test.db",).  Does it
> > mean
> > > sqlite3 does not support
> > > UTF16 encoding ?
> > > or
> > > Am i missing some package ?
> > >
> > > Thanks,
> > > Pavan.
> >
> >
> > -
> > To unsubscribe, send email to [EMAIL PROTECTED]
> >
> > -
> >
> >
> 
> 


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] UTF16 Encoding

2007-02-28 Thread Brownie

I tried this call. It works. But, the db file is created only with the first
character name
and the extenstion is also missing. (its like 't')


I think that your compiler's wchar_t is 32bit.
But sqlite3_open16() requires 16bit characters.

Try the following code.

sqlite3_open16( "t\0e\0s\0t\0.\0d\0b\0\0",  );

Regards,

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] UTF16 Encoding

2007-02-28 Thread Pavan

Hi Lucas,


Shouldn't it be "sqlite3_open16(L"test.db",)" ?


I tried this call. It works. But, the db file is created only with the first
character name
and the extenstion is also missing. (its like 't')

Also, can you point to me at some documentation which explains what does
the 'L' mean in the API ?

Thanks,
Pavan.


On 2/28/07, Nuno Lucas <[EMAIL PROTECTED]> wrote:


On 2/28/07, Pavan <[EMAIL PROTECTED]> wrote:
> Hi,
>
> When i tried to create the db file using API sqlite3_open16("test.db
",)
> it creats the file name with some junk
> characters.

Shouldn't it be "sqlite3_open16(L"test.db",)" ?

Regards,
~Nuno Lucas

> The file name is correct if i use sqlite3_open("test.db",).  Does it
mean
> sqlite3 does not support
> UTF16 encoding ?
> or
> Am i missing some package ?
>
> Thanks,
> Pavan.


-
To unsubscribe, send email to [EMAIL PROTECTED]

-





--
'
Always finish stronger than you start
*


Re: [sqlite] UTF16 Encoding

2007-02-28 Thread Nuno Lucas

On 2/28/07, Pavan <[EMAIL PROTECTED]> wrote:

Hi,

When i tried to create the db file using API sqlite3_open16("test.db",)
it creats the file name with some junk
characters.


Shouldn't it be "sqlite3_open16(L"test.db",)" ?

Regards,
~Nuno Lucas


The file name is correct if i use sqlite3_open("test.db",).  Does it mean
sqlite3 does not support
UTF16 encoding ?
or
Am i missing some package ?

Thanks,
Pavan.


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] UTF16 Encoding

2007-02-28 Thread Pavan

Hi,

When i tried to create the db file using API sqlite3_open16("test.db",)
it creats the file name with some junk
characters.
The file name is correct if i use sqlite3_open("test.db",).  Does it mean
sqlite3 does not support
UTF16 encoding ?
or
Am i missing some package ?

Thanks,
Pavan.

--
'
Always finish stronger than you start
*