/ Check-in [4fba2db3]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix the utf8 to utf16 conversion routine for short strings. Bug introduced by check-in (2817). (CVS 2821)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4fba2db38e0693be52ca7251e4958bd836607f05
User & Date: drh 2005-12-15 22:34:01
Context
2005-12-16
01:06
Initial infrastructure for recognizing DESC indices and being able to read and write older databases that specify DESC indices but do not really use them. Nothing is close to working yet. (CVS 2822) check-in: cd110aa2 user: drh tags: trunk
2005-12-15
22:34
Fix the utf8 to utf16 conversion routine for short strings. Bug introduced by check-in (2817). (CVS 2821) check-in: 4fba2db3 user: drh tags: trunk
15:22
Add the sqlite3_update_hook() API. (CVS 2820) check-in: 36229018 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/utf.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used to translate between UTF-8, 
    13     13   ** UTF-16, UTF-16BE, and UTF-16LE.
    14     14   **
    15         -** $Id: utf.c,v 1.34 2005/12/15 03:04:11 drh Exp $
           15  +** $Id: utf.c,v 1.35 2005/12/15 22:34:01 drh Exp $
    16     16   **
    17     17   ** Notes on UTF-8:
    18     18   **
    19     19   **   Byte-0    Byte-1    Byte-2    Byte-3    Value
    20     20   **  0xxxxxxx                                 00000000 00000000 0xxxxxxx
    21     21   **  110yyyyy  10xxxxxx                       00000000 00000yyy yyxxxxxx
    22     22   **  1110zzzz  10yyyyyy  10xxxxxx             00000000 zzzzyyyy yyxxxxxx
................................................................................
   458    458   ** NULL is returned if there is an allocation error.
   459    459   */
   460    460   char *sqlite3utf16to8(const void *z, int nByte){
   461    461     Mem m;
   462    462     memset(&m, 0, sizeof(m));
   463    463     sqlite3VdbeMemSetStr(&m, z, nByte, SQLITE_UTF16NATIVE, SQLITE_STATIC);
   464    464     sqlite3VdbeChangeEncoding(&m, SQLITE_UTF8);
   465         -  return m.z;
          465  +  assert( m.flags & MEM_Term );
          466  +  assert( m.flags & MEM_Str );
          467  +  return (m.flags & MEM_Dyn)!=0 ? m.z : sqlite3StrDup(m.z);
   466    468   }
   467    469   
   468    470   /*
   469    471   ** pZ is a UTF-16 encoded unicode string. If nChar is less than zero,
   470    472   ** return the number of bytes up to (but not including), the first pair
   471    473   ** of consecutive 0x00 bytes in pZ. If nChar is not less than zero,
   472    474   ** then return the number of bytes in the first nChar unicode characters