From: Nguyen Thai Ngoc Duy Date: Tue, 04 Sep 2012 01:31:03 GMT Subject: Re: [PATCH] fetch: align new ref summary printout in UTF-8 locales Message-ID: In-Reply-To: <7vwr0aewlf.fsf@alter.siamese.dyndns.org> On Tue, Sep 4, 2012 at 2:26 AM, Junio C Hamano wrote: > Nguyễn Thái Ngọc Duy 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. Hmm.. I did test with zh_CN.UTF-8 and it seemed to work. I'll check this again. -- Duy