pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedprint formated special characteres
5+ messages / 5 participants
[nested] [flat]
* print formated special characteres
@ 2020-10-17 18:37 Celso Lorenzetti <celso@sysrs.com.br>
2020-10-17 18:51 ` Re: print formated special characteres Matthias Apitz <guru@unixarea.de>
0 siblings, 1 reply; 5+ messages in thread
From: Celso Lorenzetti @ 2020-10-17 18:37 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi all,
Somebody help me, please.
How to make the texts are aligned with 10 characters?
elog(INFO, "\n%-10s Fim\n%-10s Fim\n", "Variável", "Variavel");
Output:
INFO:
Variável Fim
Variavel Fim
thank you
Att,
Assinatura Outlook
--
Este email foi escaneado pelo Avast antivírus.
https://www.avast.com/antivirus
Attachments:
image001.jpg (image/jpeg, 13.1K) download
view image
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: print formated special characteres
2020-10-17 18:37 print formated special characteres Celso Lorenzetti <celso@sysrs.com.br>
@ 2020-10-17 18:51 ` Matthias Apitz <guru@unixarea.de>
2020-10-17 22:44 ` Re: print formated special characteres Peter J. Holzer <hjp-pgsql@hjp.at>
0 siblings, 1 reply; 5+ messages in thread
From: Matthias Apitz @ 2020-10-17 18:51 UTC (permalink / raw)
To: Celso Lorenzetti <celso@sysrs.com.br>; +Cc: pgsql-general@lists.postgresql.org
El día sábado, octubre 17, 2020 a las 03:37:46p. m. -0300, Celso Lorenzetti escribió:
> Somebody help me, please.
>
> How to make the texts are aligned with 10 characters?
>
>
>
> elog(INFO, "\n%-10s Fim\n%-10s Fim\n", "Variável", "Variavel");
Hola Celso,
You can reproduce the same on the UNIX shell with:
$ printf "\n%-10s Fim\n%-10s Fim\n" "Variável" "Variavel"
Variável Fim
Variavel Fim
$ printf "\n%-10s Fim\n%-10s Fim\n" "VariXvel" "Variavel"
VariXvel Fim
Variavel Fim
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.
I have no solution, though at the moment...
Obrigado
matthias
--
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
Без книги нет знания, без знания нет коммунизма (Влaдимир Ильич Ленин)
Without books no knowledge - without knowledge no communism (Vladimir Ilyich Lenin)
Sin libros no hay saber - sin saber no hay comunismo. (Vladimir Ilich Lenin)
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: print formated special characteres
2020-10-17 18:37 print formated special characteres Celso Lorenzetti <celso@sysrs.com.br>
2020-10-17 18:51 ` Re: print formated special characteres Matthias Apitz <guru@unixarea.de>
@ 2020-10-17 22:44 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2020-10-17 23:07 ` Re: print formated special characteres Tom Lane <tgl@sss.pgh.pa.us>
2020-10-19 03:33 ` Re: print formated special characteres Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 2 replies; 5+ messages in thread
From: Peter J. Holzer @ 2020-10-17 22:44 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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ó:
>
> > Somebody help me, please.
> >
> > How to make the texts are aligned with 10 characters?
> >
> >
> >
> > elog(INFO, "\n%-10s Fim\n%-10s Fim\n", "Variável", "Variavel");
Which programming language is this? PL/pgSQL?
> Hola Celso,
>
> You can reproduce the same on the UNIX shell with:
>
> $ printf "\n%-10s Fim\n%-10s Fim\n" "Variável" "Variavel"
>
> Variável Fim
> Variavel Fim
Hmm. Zsh gets it right:
trintignant:~ 0:31 :-) 1032% printf "\n%-10s Fim\n%-10s Fim\n" "Variável" "Variavel"
Variável Fim
Variavel Fim
As do Perl and Python.
> 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.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: print formated special characteres
2020-10-17 18:37 print formated special characteres Celso Lorenzetti <celso@sysrs.com.br>
2020-10-17 18:51 ` Re: print formated special characteres Matthias Apitz <guru@unixarea.de>
2020-10-17 22:44 ` Re: print formated special characteres Peter J. Holzer <hjp-pgsql@hjp.at>
@ 2020-10-17 23:07 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 5+ messages in thread
From: Tom Lane @ 2020-10-17 23:07 UTC (permalink / raw)
To: Peter J. Holzer <hjp-pgsql@hjp.at>; +Cc: pgsql-general@lists.postgresql.org
"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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: print formated special characteres
2020-10-17 18:37 print formated special characteres Celso Lorenzetti <celso@sysrs.com.br>
2020-10-17 18:51 ` Re: print formated special characteres Matthias Apitz <guru@unixarea.de>
2020-10-17 22:44 ` Re: print formated special characteres Peter J. Holzer <hjp-pgsql@hjp.at>
@ 2020-10-19 03:33 ` Pavel Stehule <pavel.stehule@gmail.com>
1 sibling, 0 replies; 5+ messages in thread
From: Pavel Stehule @ 2020-10-19 03:33 UTC (permalink / raw)
To: celso@sysrs.com.br; +Cc: Peter J. Holzer <hjp-pgsql@hjp.at>; pgsql-general <pgsql-general@lists.postgresql.org>
po 19. 10. 2020 v 3:18 odesílatel Celso Lorenzetti <celso@sysrs.com.br>
napsal:
> Hi Peter,
>
> is language C standart..
>
> 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ó:
> >
> > > Somebody help me, please.
> > >
> > > How to make the texts are aligned with 10 characters?
> > >
> > >
> > >
> > > elog(INFO, "\n%-10s Fim\n%-10s Fim\n", "Variável", "Variavel");
>
> Which programming language is this? PL/pgSQL?
>
This is an internal function available in internal C API.
As Tom Lane said in other mail - this internal API just doesn't support
alignment for multibyte encodings.
Regards
Pavel
>
> > Hola Celso,
> >
> > You can reproduce the same on the UNIX shell with:
> >
> > $ printf "\n%-10s Fim\n%-10s Fim\n" "Variável" "Variavel"
> >
> > Variável Fim
> > Variavel Fim
>
> Hmm. Zsh gets it right:
>
> trintignant:~ 0:31 :-) 1032% printf "\n%-10s Fim\n%-10s Fim\n" "Variável"
> "Variavel"
>
> Variável Fim
> Variavel Fim
>
> As do Perl and Python.
>
>
> > 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.
>
> hp
>
> --
> _ | Peter J. Holzer | Story must make more sense than reality.
> |_|_) | |
> | | | hjp@hjp.at | -- Charles Stross, "Creative writing
> __/ | http://www.hjp.at/ | challenge!"
>
>
> --
> Este email foi escaneado pelo Avast antivírus.
> https://www.avast.com/antivirus
>
>
>
>
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-10-19 03:33 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-10-17 18:37 print formated special characteres Celso Lorenzetti <celso@sysrs.com.br>
2020-10-17 18:51 ` Matthias Apitz <guru@unixarea.de>
2020-10-17 22:44 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2020-10-17 23:07 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-10-19 03:33 ` Pavel Stehule <pavel.stehule@gmail.com>
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