aboutsummaryrefslogtreecommitdiff
path: root/src/func.c
diff options
context:
space:
mode:
authordrh <>2025-02-25 11:47:34 +0000
committerdrh <>2025-02-25 11:47:34 +0000
commita357a90f12e927ec169168cd89e54dc4fa905717 (patch)
tree17d1145c01c157b77094b27a4ae59765ed9b6b2d /src/func.c
parentc46fbec350c4a0a71410bd32384e59ac27a799d5 (diff)
downloadsqlite-a357a90f12e927ec169168cd89e54dc4fa905717.tar.gz
sqlite-a357a90f12e927ec169168cd89e54dc4fa905717.zip
Consolidate two different UTF8 encoders into a single subroutine.
FossilOrigin-Name: 6208e494858b9d362efc7db4e8aac6f8e93fe51d2e038c94dfa97c55a74688a0
Diffstat (limited to 'src/func.c')
-rw-r--r--src/func.c36
1 files changed, 4 insertions, 32 deletions
diff --git a/src/func.c b/src/func.c
index 124dabe31..d8c812759 100644
--- a/src/func.c
+++ b/src/func.c
@@ -1150,34 +1150,6 @@ void sqlite3QuoteValue(StrAccum *pStr, sqlite3_value *pValue, int bEscape){
}
/*
-** Write a single UTF8 character whose value if v into the
-** buffer starting at zOut. Return the number of bytes needed
-** to encode that character.
-*/
-static int appendOneUtf8Char(char *zOut, u32 v){
- if( v<0x00080 ){
- zOut[0] = (u8)(v & 0xff);
- return 1;
- }
- if( v<0x00800 ){
- zOut[0] = 0xc0 + (u8)((v>>6) & 0x1f);
- zOut[1] = 0x80 + (u8)(v & 0x3f);
- return 2;
- }
- if( v<0x10000 ){
- zOut[0] = 0xe0 + (u8)((v>>12) & 0x0f);
- zOut[1] = 0x80 + (u8)((v>>6) & 0x3f);
- zOut[2] = 0x80 + (u8)(v & 0x3f);
- return 3;
- }
- zOut[0] = 0xf0 + (u8)((v>>18) & 0x07);
- zOut[1] = 0x80 + (u8)((v>>12) & 0x3f);
- zOut[2] = 0x80 + (u8)((v>>6) & 0x3f);
- zOut[3] = 0x80 + (u8)(v & 0x3f);
- return 4;
-}
-
-/*
** Return true if z[] begins with N hexadecimal digits, and write
** a decoding of those digits into *pVal. Or return false if any
** one of the first N characters in z[] is not a hexadecimal digit.
@@ -1248,19 +1220,19 @@ static void unistrFunc(
}else if( sqlite3Isxdigit(zIn[i+1]) ){
if( !isNHex(&zIn[i+1], 4, &v) ) goto unistr_error;
i += 5;
- j += appendOneUtf8Char(&zOut[j], v);
+ j += sqlite3AppendOneUtf8Character(&zOut[j], v);
}else if( zIn[i+1]=='+' ){
if( !isNHex(&zIn[i+2], 6, &v) ) goto unistr_error;
i += 8;
- j += appendOneUtf8Char(&zOut[j], v);
+ j += sqlite3AppendOneUtf8Character(&zOut[j], v);
}else if( zIn[i+1]=='u' ){
if( !isNHex(&zIn[i+2], 4, &v) ) goto unistr_error;
i += 6;
- j += appendOneUtf8Char(&zOut[j], v);
+ j += sqlite3AppendOneUtf8Character(&zOut[j], v);
}else if( zIn[i+1]=='U' ){
if( !isNHex(&zIn[i+2], 8, &v) ) goto unistr_error;
i += 10;
- j += appendOneUtf8Char(&zOut[j], v);
+ j += sqlite3AppendOneUtf8Character(&zOut[j], v);
}else{
goto unistr_error;
}