diff options
author | drh <> | 2025-05-31 20:51:42 +0000 |
---|---|---|
committer | drh <> | 2025-05-31 20:51:42 +0000 |
commit | c0190101d14bca3664689c53b432c4de969905a2 (patch) | |
tree | b716d54adccea537eb5fa758df50bd04927d046c /src | |
parent | 0d3e5ca28e858335c231cdbc11c01b7b4945a5db (diff) | |
download | sqlite-c0190101d14bca3664689c53b432c4de969905a2.tar.gz sqlite-c0190101d14bca3664689c53b432c4de969905a2.zip |
Enhance "box" and "column" mode formatting in the CLI to better deal with
double-wide characters.
FossilOrigin-Name: b0de22ed0abf2ea5d269f191c884d7b2be167a2ed27018c25aaa0ea238cd621a
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 8660bd78a..363685eb0 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -887,12 +887,21 @@ static int strlen30(const char *z){ /* ** Return the length of a string in characters. Multibyte UTF8 characters -** count as a single character. +** count as a single character for single-width characters, or as two +** characters for double-width characters. */ static int strlenChar(const char *z){ int n = 0; while( *z ){ - if( (0xc0&*(z++))!=0x80 ) n++; + if( (0x80&z[0])==0 ){ + n++; + z++; + }else{ + int u = 0; + int len = decodeUtf8((const u8*)z, &u); + z += len; + n += cli_wcwidth(u); + } } return n; } |