Overview
| SHA1 Hash: | ff67d87894eeb0036374235c5723e267536909f9 |
|---|---|
| Date: | 2013-03-01 15:02:52 |
| User: | drh |
| Comment: | Fix the handling of UTF16 surrogate pairs in the char() function. |
Tags And Properties
- branch=trunk inherited from [704b122e53]
- sym-trunk inherited from [704b122e53]
Changes
Changes to src/func.c
995 for(i=0; i<argc; i++){ 995 for(i=0; i<argc; i++){ 996 sqlite3_int64 x; 996 sqlite3_int64 x; 997 unsigned c; 997 unsigned c; 998 x = sqlite3_value_int64(argv[i]); 998 x = sqlite3_value_int64(argv[i]); 999 if( x<0 || x>0x10ffff ) x = 0xfffd; 999 if( x<0 || x>0x10ffff ) x = 0xfffd; 1000 c = (unsigned)(x & 0x1fffff); 1000 c = (unsigned)(x & 0x1fffff); 1001 if( c<=0xFFFF ){ 1001 if( c<=0xFFFF ){ > 1002 if( c>=0xd800 && c<=0xdfff ) c = 0xfffd; 1002 *zOut++ = (u8)(c&0x00FF); 1003 *zOut++ = (u8)(c&0x00FF); 1003 *zOut++ = (u8)((c>>8)&0x00FF); 1004 *zOut++ = (u8)((c>>8)&0x00FF); 1004 }else{ 1005 }else{ 1005 if( c>=0xd800 && c<=0xdbff ) c = 0xfffd; < 1006 *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); 1006 *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0)); 1007 *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); 1007 *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03)); 1008 *zOut++ = (u8)(c&0x00FF); 1008 *zOut++ = (u8)(c&0x00FF); 1009 *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); 1009 *zOut++ = (u8)(0x00DC + ((c>>8)&0x03)); 1010 } 1010 } 1011 } 1011 } 1012 sqlite3_result_text16le(context, (char*)z, (int)(zOut-z), sqlite3_free); 1012 sqlite3_result_text16le(context, (char*)z, (int)(zOut-z), sqlite3_free);