1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-21 11:13:54 +03:00

Fix the handling of UTF16 surrogate pairs in the char() function.

FossilOrigin-Name: ff67d87894eeb0036374235c5723e267536909f9
This commit is contained in:
drh
2013-03-01 15:02:52 +00:00
parent 503a686e09
commit de97724827
3 changed files with 8 additions and 8 deletions

View File

@@ -999,10 +999,10 @@ static void charFunc(
if( x<0 || x>0x10ffff ) x = 0xfffd;
c = (unsigned)(x & 0x1fffff);
if( c<=0xFFFF ){
if( c>=0xd800 && c<=0xdfff ) c = 0xfffd;
*zOut++ = (u8)(c&0x00FF);
*zOut++ = (u8)((c>>8)&0x00FF);
}else{
if( c>=0xd800 && c<=0xdbff ) c = 0xfffd;
*zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));
*zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));
*zOut++ = (u8)(c&0x00FF);