aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2024-11-05 23:26:31 +0000
committerdrh <>2024-11-05 23:26:31 +0000
commitedf7efc61cc65f9e5695017cb7e1eaba8c6a74d5 (patch)
tree6998113f61fc8041e6fd3f586fb65abe77d98602 /src
parent19c4fa92dda7ed7e2fee4d91fb3be456b59e83c7 (diff)
downloadsqlite-edf7efc61cc65f9e5695017cb7e1eaba8c6a74d5.tar.gz
sqlite-edf7efc61cc65f9e5695017cb7e1eaba8c6a74d5.zip
Improve the ".mode json" output of the CLI so that it encodes U+007f using
an escape sequence. FossilOrigin-Name: 8b58cf9bbd3090c60f1ee7468cdeeb0b0fa4560d1e51a5fd0bef43692d10fe04
Diffstat (limited to 'src')
-rw-r--r--src/shell.c.in10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/shell.c.in b/src/shell.c.in
index cdd09becf..180768b7f 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -2037,8 +2037,8 @@ const char *zSkipValidUtf8(const char *z, int nAccept, long ccm){
const char *pcLimit = (nAccept>=0)? z+nAccept : 0;
assert(z!=0);
while( (pcLimit)? (z<pcLimit) : (ng-- != 0) ){
- char c = *z;
- if( (c & 0x80) == 0 ){
+ unsigned char c = *(u8*)z;
+ if( c<0x7f ){
if( ccm != 0L && c < 0x20 && ((1L<<c) & ccm) != 0 ) return z;
++z; /* ASCII */
}else if( (c & 0xC0) != 0xC0 ) return z; /* not a lead byte */
@@ -2106,7 +2106,7 @@ static void output_c_string(FILE *out, const char *z){
}
/*
-** Output the given string as a quoted according to JSON quoting rules.
+** Output the given string as quoted according to JSON quoting rules.
*/
static void output_json_string(FILE *out, const char *z, i64 n){
char c;
@@ -2144,8 +2144,8 @@ static void output_json_string(FILE *out, const char *z, i64 n){
if( cbsSay ){
ace[1] = cbsSay;
sqlite3_fputs(ace, out);
- }else if( c<=0x1f ){
- sqlite3_fprintf(out, "u%04x", c);
+ }else if( c<=0x1f || c==0x7f ){
+ sqlite3_fprintf(out, "\\u%04x", c);
}else{
ace[1] = (char)c;
sqlite3_fputs(ace+1, out);