SQLite

View Ticket
Login
Ticket Hash: 6c266900a22574d4d6474503da5bfe849c8b244f
Title: shell: The column mode (and width option) does not manage correctly UTF-8
Status: Fixed Type: Feature_Request
Severity: Minor Priority: Low
Subsystem: Shell Resolution: Fixed
Last Modified: 2022-11-11 13:17:24
Version Found In: 3.7.13
User Comments:
nobody added on 2013-01-02 00:08:44:

Hello,

Martin Godisch notes that sqlite3 CLI doesn't count multi-byte characters correctly. He uses an example with the width option to highlight the problem. However, I think this is the column mode that does not comply with UTF-8, rather than the width option.

This bug has been detected by Martin Godisch in version 3.5.9 packaged for Debian (see Debian Bug report: #536662) and I still found it in version 3.7.13 (packaged for Debian also). I use the sqlite3 3.7.13-1 package (see debian specific patch information for this package) for Debian testing on an x86 architecture, without modifications.

The following script illustrates the problem:

.header on

create table tbl1 (col1 text primary key);

insert into tbl1 values ('123456');
insert into tbl1 values ('abcdef');
insert into tbl1 values ('äöüäöü');

select col1 from tbl1;
select substr(col1, 1, 4) as col1 from tbl1;

.mode column
select col1 from tbl1;

.width 4
select col1 from tbl1;

Script output:

col1
123456
abcdef
äöüäöü

col1
1234
abcd
äöüä

col1      
----------
123456    
abcdef    
äöüäö

col1
----
1234
abcd
äö

Regards,

Stéphane Aulery


Attachments: