utf.c File Reference

Go to the source code of this file.

Defines

#define WRITE_UTF8(zOut, c)
#define WRITE_UTF16LE(zOut, c)
#define WRITE_UTF16BE(zOut, c)
#define READ_UTF16LE(zIn, c)
#define READ_UTF16BE(zIn, c)
#define READ_UTF8(zIn, zTerm, c)

Functions

int sqlite3Utf8Read (const unsigned char *z, const unsigned char *zTerm, const unsigned char **pzNext)
int sqlite3VdbeMemTranslate (Mem *pMem, u8 desiredEnc)
int sqlite3VdbeMemHandleBom (Mem *pMem)
int sqlite3Utf8CharLen (const char *zIn, int nByte)
char * sqlite3Utf16to8 (sqlite3 *db, const void *z, int nByte)
int sqlite3Utf16ByteLen (const void *zIn, int nChar)

Variables

const int sqlite3one = 1
static const unsigned char sqlite3UtfTrans1 []

Define Documentation

#define READ_UTF16BE ( zIn,
 ) 
Value:
{                                         \
  c = ((*zIn++)<<8);                                                  \
  c += (*zIn++);                                                      \
  if( c>=0xD800 && c<0xE000 ){                                       \
    int c2 = ((*zIn++)<<8);                                           \
    c2 += (*zIn++);                                                   \
    c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \
    if( (c & 0xFFFF0000)==0 ) c = 0xFFFD;                             \
  }                                                                   \
}

Definition at line 119 of file utf.c.

Referenced by sqlite3Utf16ByteLen(), and sqlite3VdbeMemTranslate().

#define READ_UTF16LE ( zIn,
 ) 
Value:
{                                         \
  c = (*zIn++);                                                       \
  c += ((*zIn++)<<8);                                                 \
  if( c>=0xD800 && c<0xE000 ){                                       \
    int c2 = (*zIn++);                                                \
    c2 += ((*zIn++)<<8);                                              \
    c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \
    if( (c & 0xFFFF0000)==0 ) c = 0xFFFD;                             \
  }                                                                   \
}

Definition at line 108 of file utf.c.

Referenced by sqlite3Utf16ByteLen(), and sqlite3VdbeMemTranslate().

#define READ_UTF8 ( zIn,
zTerm,
 ) 
Value:
c = *(zIn++);                                            \
  if( c>=0xc0 ){                                           \
    c = sqlite3UtfTrans1[c-0xc0];                          \
    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \
      c = (c<<6) + (0x3f & *(zIn++));                      \
    }                                                      \
    if( c<0x80                                             \
        || (c&0xFFFFF800)==0xD800                          \
        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \
  }

Definition at line 157 of file utf.c.

Referenced by sqlite3Utf8Read(), and sqlite3VdbeMemTranslate().

#define WRITE_UTF16BE ( zOut,
 ) 
Value:
{                                \
  if( c<=0xFFFF ){                                              \
    *zOut++ = ((c>>8)&0x00FF);                                  \
    *zOut++ = (c&0x00FF);                                       \
  }else{                                                        \
    *zOut++ = (0x00D8 + (((c-0x10000)>>18)&0x03));              \
    *zOut++ = (((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \
    *zOut++ = (0x00DC + ((c>>8)&0x03));                         \
    *zOut++ = (c&0x00FF);                                       \
  }                                                             \
}

Definition at line 96 of file utf.c.

Referenced by sqlite3VdbeMemTranslate().

#define WRITE_UTF16LE ( zOut,
 ) 
Value:
{                                \
  if( c<=0xFFFF ){                                              \
    *zOut++ = (c&0x00FF);                                       \
    *zOut++ = ((c>>8)&0x00FF);                                  \
  }else{                                                        \
    *zOut++ = (((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \
    *zOut++ = (0x00D8 + (((c-0x10000)>>18)&0x03));              \
    *zOut++ = (c&0x00FF);                                       \
    *zOut++ = (0x00DC + ((c>>8)&0x03));                         \
  }                                                             \
}

Definition at line 84 of file utf.c.

Referenced by sqlite3VdbeMemTranslate().

#define WRITE_UTF8 ( zOut,
 ) 
Value:
{                          \
  if( c<0x00080 ){                                     \
    *zOut++ = (c&0xFF);                                \
  }                                                    \
  else if( c<0x00800 ){                                \
    *zOut++ = 0xC0 + ((c>>6)&0x1F);                    \
    *zOut++ = 0x80 + (c & 0x3F);                       \
  }                                                    \
  else if( c<0x10000 ){                                \
    *zOut++ = 0xE0 + ((c>>12)&0x0F);                   \
    *zOut++ = 0x80 + ((c>>6) & 0x3F);                  \
    *zOut++ = 0x80 + (c & 0x3F);                       \
  }else{                                               \
    *zOut++ = 0xF0 + ((c>>18) & 0x07);                 \
    *zOut++ = 0x80 + ((c>>12) & 0x3F);                 \
    *zOut++ = 0x80 + ((c>>6) & 0x3F);                  \
    *zOut++ = 0x80 + (c & 0x3F);                       \
  }                                                    \
}

Definition at line 64 of file utf.c.

Referenced by sqlite3VdbeMemTranslate().


Function Documentation

int sqlite3Utf16ByteLen ( const void *  zIn,
int  nChar 
)

Definition at line 452 of file utf.c.

References READ_UTF16BE, READ_UTF16LE, SQLITE_UTF16BE, and SQLITE_UTF16NATIVE.

Referenced by sqlite3Prepare16().

char* sqlite3Utf16to8 ( sqlite3 db,
const void *  z,
int  nByte 
)
int sqlite3Utf8CharLen ( const char *  zIn,
int  nByte 
)

Definition at line 375 of file utf.c.

References SQLITE_SKIP_UTF8.

Referenced by likeFunc(), sqlite3AlterRenameTable(), sqlite3EndTable(), and sqlite3Prepare16().

int sqlite3Utf8Read ( const unsigned char *  z,
const unsigned char *  zTerm,
const unsigned char **  pzNext 
)

Definition at line 168 of file utf.c.

References READ_UTF8.

int sqlite3VdbeMemHandleBom ( Mem pMem  ) 
int sqlite3VdbeMemTranslate ( Mem pMem,
u8  desiredEnc 
)

Variable Documentation

const int sqlite3one = 1

Definition at line 46 of file utf.c.

const unsigned char sqlite3UtfTrans1[] [static]
Initial value:
 {
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,
}

Definition at line 52 of file utf.c.


ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:50:02 2011 by Doxygen 1.6.1