On 2018-02-17 18:39, Ralf Junker wrote:
Example SQL:

   length(printf ('%4s', 'abc')),
   length(printf ('%4s', 'äöü')),
   length(printf ('%-4s', 'abc')),
   length(printf ('%-4s', 'äöü'))

Output is 4, 3, 4, 3. Padding seems to take into account UTF-8 bytes instead of UTF-8 code points.

Should padding not work on code points and output 4 in all cases as requested?

If you are interested in a patch extending a functionality of ``printf()'' then http://sqlite.chncc.eu/utf8printf/. Adding ``l'' length modifier makes width/precision specifications being treated as numbers of UTF-8 chars -- not bytes. ``SELECT length(printf ('%4ls', 'äöü'));'' will give 4.

-- best regards

Cezary H. Noweta
sqlite-users mailing list

Reply via email to