On Sat, May 22, 2010 at 09:23:06AM -0500, Black, Michael (IS) scratched on the 
> I think you're making the mistake of thinking that the entire SQL
> string is UTF-16.

  It is.  That's the whole point of the "16" interfaces.

> 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. */

  Yes, I know it says that in the source next to the function, but
  that's wrong.  Following the source confirms that.  A set of
  copy-paste errors, no doubt.  The website (and the prototypes in the
  source) are correct:


     int sqlite3_prepare16_v2(
       sqlite3 *db,            /* Database handle */
       const void *zSql,       /* SQL statement, UTF-16 encoded */
       int nByte,              /* Maximum length of zSql in bytes. */
       sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
       const void **pzTail     /* OUT: Pointer to unused portion of zSql */

> It's your data fields that get encoded.

  Not exactly.  The database has a single encoding for all text values.
  Any text values that are recorded in the database are converted to that

  Consider bind values.  You can specify input values in whatever
  encoding you want.  SQLite will convert them to whatever the
  database encoding is before recording them.  It works the same on
  output, where you can request a column in whatever encoding you want,
  regardless of the database encoding.

  sqlite3_open() and sqlite3_open16() are a bit different.  In addition
  to the filename, using sqlite3_open16() to create a database will set
  the global database encoding to UTF-16.  But that has a whole different
  set of issues, which is why there is no sqlite3_open16_v2().


Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
sqlite-users mailing list

Reply via email to