From: Johannes Sixt <j6t@kdbg.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] fetch: align new ref summary printout in UTF-8 locales
Date: Mon, 03 Sep 2012 22:01:17 +0200 [thread overview]
Message-ID: <50450C8D.7010301@kdbg.org> (raw)
In-Reply-To: <7vwr0aewlf.fsf@alter.siamese.dyndns.org>
Am 03.09.2012 21:26, schrieb Junio C Hamano:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> 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
next prev parent reply other threads:[~2012-09-03 20:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-03 11:10 [PATCH] fetch: align new ref summary printout in UTF-8 locales Nguyễn Thái Ngọc Duy
2012-09-03 19:26 ` Junio C Hamano
2012-09-03 20:01 ` Johannes Sixt [this message]
2012-09-03 20:30 ` Junio C Hamano
2012-09-04 1:31 ` Nguyen Thai Ngoc Duy
2012-09-04 10:39 ` [PATCH v2] " Nguyễn Thái Ngọc Duy
[not found] ` <504796A5.4070700@gmail.com>
2012-09-05 19:20 ` Torsten Bögershausen
2012-09-06 12:11 ` Nguyen Thai Ngoc Duy
2012-09-06 15:36 ` Nguyen Thai Ngoc Duy
2012-09-06 16:21 ` Torsten Bögershausen
2012-09-06 18:08 ` Junio C Hamano
2012-09-12 14:02 ` Nguyen Thai Ngoc Duy
2012-09-12 18:02 ` Junio C Hamano
2012-09-12 20:12 ` Torsten Bögershausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50450C8D.7010301@kdbg.org \
--to=j6t@kdbg.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.