sqlite3: .width counts bytes, not characters
[email protected] Mon, 9 Mar 2020 21:02:18 +0100
| Newsgroups | gmane.comp.db.sqlite.general |
|---|---|
| Message-ID | <trinity-2fb41dec-6454-47cc-bf08-6ace8c60b951-1583784138621@3c-app-gmx-bap25> |
Hi
I use sqlite3 (sqlite3 --version = "3.11.0 2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f" on Ubuntu 16.04.6 LTS) for formatted output. '.width' does not behave as I expected when non-ASCII Unicode characters are printed. It seems that .width counts bytes and not characters. See test case below (in case the email does not display non-ASCII characters properly: the second INSERT has 6 characters '3/4' as first field). Is there an option to format the output nicely in columns when non-ASCII characters may be included?
Test case:
echo "CREATE TEMPORARY TABLE width_test (data, description);" > width_test.sql
echo "INSERT INTO width_test VALUES('aaaaaa', '6 ASCII letters');" >> width_test.sql
echo "INSERT INTO width_test VALUES('¾¾¾¾¾¾', '6 non-AScII letters');" >> width_test.sql
echo ".mode col" >> width_test.sql
echo ".width 6 20" >> width_test.sql
echo "SELECT * FROM width_test;" >> width_test.sql
echo ".width 9 20" >> width_test.sql
echo "SELECT * FROM width_test;" >> width_test.sql
echo ".width 12 20" >> width_test.sql
echo "SELECT * FROM width_test;" >> width_test.sql
cat width_test.sql | sqlite3 "test.db"
Best regards
Andreas
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users