SQLite Forum

Wide Characters not aligned in column mode
Login

Wide Characters not aligned in column mode

(1) By polm23 on 2020-09-04 08:43:22 [link]

Not sure if this is out of scope or not, but when wide characters are present in column output mode they're still treated as one character wide, so column widths are wrong and text is misaligned. For example:

```
source                                    dest             
----------------------------------------  -----------------
Final Fantasy 7 (Famicom)                 Final Fantasy VII
最终幻想7                                     Final Fantasy VII
Shenzhen Nanjing Technology               Final Fantasy VII
Final Fantasy VII (Famicom)               Final Fantasy VII
```

There are various ways to check the printed width of a character, on Linux you can use wcwidth for example. 

If this is in scope, it'd be great to have it fixed.

(2) By Simon Slavin (slavin) on 2020-09-04 13:21:44 in reply to 1

Sorry, but you're right: it's not in scope.  The shell tool is intended for development and debugging, though some people use it to read and generate text files used elsewhere.  It doesn't make adjustments for the numerous platforms it has to run on, and doesn't understand Unicode.

I think you've highlighted a point where you need to use software which isn't included in the SQLite downloads.

(3) By polm23 on 2020-09-04 14:49:43 in reply to 2 [link]

OK, good to know. Thanks for the quick response!

(4) By Richard Damon (RichardDamon) on 2020-09-04 16:00:42 in reply to 1 [link]

Basically, the CLI assumes for column mode that you are using a mono-space font, which if you are using 'wide' characters isn't true. This is to allow it to be simple and universal.

Yes, a 'smarter' program could use some system dependant tool to figure out how wide a string was, and format better, but that is beyond to scope of the CLI