SQLite4
Check-in [5cd50e225c]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add a note to www/porting.wiki describing the changes to utf-16 support.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5cd50e225ccc9c9c2f7ee575106bb37d7c61520c
User & Date: dan 2013-06-11 17:27:33
Context
2013-06-12
19:20
Add file selectF.test. check-in: 9678daa99f user: dan tags: trunk
2013-06-11
17:27
Add a note to www/porting.wiki describing the changes to utf-16 support. check-in: 5cd50e225c user: dan tags: trunk
16:48
Remove legacy API functions: complete16(), errmsg16(), column_name16(), column_database_name16(), column_table_name16(), column_origin_name16(), column_decltype16(), create_function16() and collation_needed16(). check-in: c7c533dddc user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to www/porting.wiki.

30
31
32
33
34
35
36














































<li><p>Check all uses of sqlite4_snprintf() and sqlite4_vnsprintf() for
    the new function signature:
<ul>
<li>The order of the first two arguments is reversed
<li>Both routines return the length of the result string.
</ul>
</ul>





















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<li><p>Check all uses of sqlite4_snprintf() and sqlite4_vnsprintf() for
    the new function signature:
<ul>
<li>The order of the first two arguments is reversed
<li>Both routines return the length of the result string.
</ul>
</ul>

<h3> UTF-16 Functions </h3>

<p>
Many SQLite3 APIs come in two flavours - UTF-8 and UTF-16. For example,
sqlite3_complete() and sqlite3_complete16(). In most cases, the only 
difference between the two versions is that one interprets or returns
text encoded using UTF-8, and the other using native byte-order utf-16.
For SQLite4, all UTF-16 APIs have been removed except the following:

<ul>
  <li> sqlite4_column_text16()
  <li> sqlite4_value_text16()
  <li> sqlite4_bind_text16()
  <li> sqlite4_result_text16()
  <li> sqlite4_result_error16()
</ul>

<p>
In place of the removed APIs, SQLite4 offers an API - sqlite4_translate() -
to translate from UTF-16 to UTF-8 and vice-versa. For example, to obtain
the current error message formated using UTF-16 (available in SQLite3
by calling sqlite3_errmsg16()), the following:

<pre>
  u16 *pError;                    /* Pointer to translated error message */
  sqlite4_buffer buf;             /* Buffer to manage memory used for pError */

  /* Initialize a buffer object. Then populate it with the utf-16 translation
  ** of the utf-8 error message returned by sqlite4_errmsg().  */
  sqlite4_buffer_init(&buf, 0);
  pError = sqlite4_translate(
      &buf, sqlite4_errmsg(db), -1, SQLITE4_TRANSLATE_UTF8_UTF16
  );

  if( pError==0 ){
    /* An out-of-memory error has occurred */
  }else{
    /* pError now points to a buffer containing the current error message
    ** encoded using native byte-order utf-16. Do something with it! */
  }

  /* Free the contents of the buffer (and hence pError) */
  sqlite4_buffer_clear(&buf);
</pre>