From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: print formated special characteres
Date: Sat, 17 Oct 2020 19:07:35 -0400
Message-ID: <145480.1602976055@sss.pgh.pa.us> (raw)
In-Reply-To: <20201017224437.GA14168@hjp.at>
References: <!&!AAAAAAAAAAAYAAAAAAAAAGBFA8ifz6xFmE1BXn1p/rXCgAAAEAAAAKNE3Hdr+WdOlJXZJZUQvU8BAAAAAA==@sysrs.com.br>
<20201017185136.GA11747@c720-r342378>
<20201017224437.GA14168@hjp.at>
"Peter J. Holzer" <hjp-pgsql@hjp.at> writes:
> On 2020-10-17 20:51:36 +0200, Matthias Apitz wrote:
>> El día sábado, octubre 17, 2020 a las 03:37:46p. m. -0300, Celso Lorenzetti escribió:
>>> elog(INFO, "\n%-10s Fim\n%-10s Fim\n", "Variável", "Variavel");
> Which programming language is this? PL/pgSQL?
Looks like C in the backend.
>> The second test (changing the accented char 'á' by 'X'), shows that the
>> problem/bug is a) more generic, not only in PostgreSQL and b) has todo
>> with being the UTF-8 char 'á' a two byte char, while 'X' is only one
>> byte.
> Yes, determining how much space a UTF-8 sequence occupies on screen is
> surprisingly hard. I'm not sure what the C standard says about that. But
> these days I would expect any programming language to get it right at
> least for the simple cases.
Our version of snprintf intentionally counts bytes not characters,
so that it does not have to make assumptions about what encoding
the given string uses. It's somewhat unclear whether the C/POSIX
standard mandates either of these interpretations. The GNU
implementation of snprintf tries to count characters. But in the
cases where that's mattered to us at all, it's generally been the
wrong thing, because glibc didn't necessarily know the encoding to
use. That's one reason why we stopped relying on libc's snprintf.
The way to get this to work as Celso wishes would be to count
characters and then do his own arithmetic about how much padding
to add.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, hjp-pgsql@hjp.at
Subject: Re: print formated special characteres
In-Reply-To: <145480.1602976055@sss.pgh.pa.us>
References: <!&!AAAAAAAAAAAYAAAAAAAAAGBFA8ifz6xFmE1BXn1p/rXCgAAAEAAAAKNE3Hdr+WdOlJXZJZUQvU8BAAAAAA==@sysrs.com.br> <20201017185136.GA11747@c720-r342378> <20201017224437.GA14168@hjp.at> <145480.1602976055@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox