Nemanja had the solution I needed.
DRH, I figured out what prepare16 was doing vs prepare as I had dug down
there with the debugger once. I think if I was preparing anything with
non-ascii characters then prepare16 is a little easier as those
characters are likely to originate it UTF-16 interfaces than in UTF-8
interfaces (talking Windows environment here). Just to be consistent, I
am using the xxx-16 interfaces for the sqlite db's that are UTF-16
encoded, and the xxx (non-16) interfaces for the UTF-8 encoded db's. My
app has need for both (unfortunately).
Thanks for your help.
[EMAIL PROTECTED] wrote:
"Nemanja Corlija" <[EMAIL PROTECTED]> wrote:
On 8/8/06, Dixon <[EMAIL PROTECTED]> wrote:
I have prepared the following wide text string:
L"SELECT ROWID FROM indext WHERE state='1' AND clientName='?' ORDER
BY size DESC"
with sqlite3_prepare16, I then call sqlite3_bind_parameter_count on the
resulting statement. I get 0 back when I expected 1. Is this an
invalid way to specify a placeholder for a variable that I will bind later?
You don't need to enclose ? with any quotes. Try it like this:
WHERE state='1' AND clientName=?
Nemanja is correct. I have an unrelated comment.
sqlite3_prepare16() will work fine for what you are doing. But
I want you to be aware that the only thing sqlite3_prepare16()
does is convert the SQL from UTF16 to UTF8 then pass the result
on to sqlite3_prepare(). This is because I do not want to bloat
the SQLite code base with separate tokenizers and parsers for
UTF-8 and UTF-16.
So there really is no benefit to using sqlite3_prepare16()
instead of sqlite3_prepare().
On the other hand, APIs like sqlite3_bind_text16() do not do
any unnecessary conversion and will use the native UTF-16 string
if that is the appropriate thing to do. There is great benefit
in using sqlite3_bind_text16() instead of sqlite3_bind_text() if
you have a UTF-16 database.
Note that it is perfectly acceptable to call sqlite3_bind_text16()
on a statement that you prepared using sqlite3_prepare(). Likewise,
you could call sqlite3_bind_text() on a statement prepared with
sqlite3_prepare16(). You do not have to stick with a single
encoding. All necessary conversions are done automatically.
--
D. Richard Hipp <[EMAIL PROTECTED]>