Thread (3 messages) flat view 3 messages, 3 authors, 2016-06-15

Re: [PATCH] fetch: align new ref summary printout in UTF-8 locales

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:54:37

Am 03.09.2012 21:26, schrieb Junio C Hamano:
Nguyễn Thái Ngọc Duy  [off-list ref] writes:
quoted
fetch does printf("%-*s", width, "foo") where "foo" can be an utf-8
string, but width is bytes, not letters. This results in misaligned
ref summary table.
"but width is bytes, not letters" is a misleading statement.

Be careful about three different quantities when talking about
aligning on terminal output with monospaced fonts:

 - How many bytes does the string occupy in memory?
 - How many unicode codepoints are in the string?
 - How many display columns does the string occupy on terminal?

Note that some "letters" (e.g. Han) occupy two display columns, and
you want to measure the "width" and compensate that for "bytes".
Letter count do not come into the picture for the purpose of aligning
the terminal output.
If I'm reading POSIX correctly, printf measures the width in %*s in bytes.

-- Hannes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help