I think you're making the mistake of thinking that the entire SQL string is 
Look at the API for sqlite3_prepare16_v2
SQLITE_API int sqlite3_prepare16_v2(
  sqlite3 *db,              /* Database handle. */
  const void *zSql,         /* UTF-8 encoded SQL statement. */

It's your data fields that get encoded.
I'm not a UTF-16 expert by any means but that's how it appears to me.
I'm surprised it works in windows -- I did confirm your error on Linux.
Michael D. Black
Senior Scientist
Northrop Grumman Mission Systems


From: sqlite-users-boun...@sqlite.org on behalf of shion
Sent: Sat 5/22/2010 7:27 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] UTF16 - sqlite3_prepare16_v2


I already found a lot of threads about the UTF16 topic, but I couldn't solve
my problem.
I have the following source code:

sqlite3_open_v2("test.sqlite", &Database, SQLITE_OPEN_READWRITE |
sqlite3_exec(Database, "PRAGMA encoding = \"UTF-16\"", 0, 0, 0);
sqlite3_prepare16_v2(Database, L"CREATE TABLE user (userID INTEGER NOT NULL
PRIMARY KEY, lastName VARCHAR(50), firstName VARCHAR(50));", -1,
&pStatement, 0);
std::cout << sqlite3_errmsg(Database) << std::endl;

The result is:
near "C": syntax error

I know that the SQL syntax is correct and it is possible to execute that
source under windows.
I don't understand why it doesn't work with Linux.
Does somebody has an idea what's going wrong?

Operating system: 2.6.31-19-generic #56-Ubuntu SMP i686 GNU/Linux
IDE: NetBeans

View this message in context: 
Sent from the SQLite mailing list archive at Nabble.com.

sqlite-users mailing list

sqlite-users mailing list

Reply via email to