Re: [PATCH 1/2] libgit.a: add some UTF-8 handling functions
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Dec 22, 2006, 21:36 UTC
- Message-ID
- <Pine.LNX.4.63.0612222233150.19693@wbgn013.biozentrum.uni-wuerzburg.de>
- In-Reply-To
- <7virg3y624.fsf@assigned-by-dhcp.cox.net>
Hi,
On Fri, 22 Dec 2006, Junio C Hamano wrote:
Show 18 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > > > This adds utf8_byte_count(), utf8_strlen() and print_wrapped_text(). > > > > The most important is probably utf8_strlen(), which returns the length > > of the text, if it is in UTF-8, otherwise -1. > > > > Note that we do not go the full nine yards: we could also check that > > the character is encoded with the minimum amount of bytes, as pointed > > out by Uwe Kleine-Koenig. > > > > The function print_wrapped_text() can be used to wrap text to a certain > > line length. > > If you do wrapped_text, I think you do not _want_ strlen (the > definition to me of strlen is "number of characters in the > string"). What you want is a function that returns the number > of columns consumed when displayed on monospace terminal.
To me, characters are the symbols occupying one "column" each. Bytes are the 8-bit thingies that you usually use to encode the characters.
Ciao, Dscho