git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] libgit.a: add some UTF-8 handling functions

From
Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de>
Date
Dec 22, 2006, 22:14 UTC
Message-ID
<20061222221448.GB2407@cepheus>
In-Reply-To
<Pine.LNX.4.63.0612222233150.19693@wbgn013.biozentrum.uni-wuerzburg.de>
Hello Johannes,
Johannes Schindelin wrote:
Show 23 quoted lines
> On Fri, 22 Dec 2006, Junio C Hamano wrote:
> 
> > 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.
Quoting utf-8(7):
	are no longer valid in UTF-8 locales.  Firstly, a single byte
	does not necessarily correspond any more to a single character.
	Secondly, since modern terminal emulators in UTF-8 mode also
	support Chinese, Japanese, and Korean double-width characters as
	well as non-spacing combining characters, outputting a single
	character does not necessarily advance the cursor by one
	position as it did in ASCII.  Library functions such as
	mbsrtowcs(3) and wcswidth(3) should be used today to count
	characters and cursor positions.

I'd prefer using a similar naming scheme. To acknowledge Junio, wcslen(3) (the wide-character equivalent of the strlen() function) counts the number of (wide-)characters in a string.

Best regards, Uwe

-- 
Uwe Kleine-König

http://www.google.com/search?q=e+%5E+%28i+pi%29
Previous: Alexander LitvinovNext: Uwe Kleine-König
Message 28 of 39 in “Fix documentation copy&paste typo”
  1. Fix documentation copy&paste typoUwe Kleine-Koenig, Dec 8, 2006
  2. Uwe Kleine-KönigDec 19, 2006
  3. Junio C HamanoDec 19, 2006
  4. specify charset for commits (Was: [PATCH] Fix documentation copy&paste typo)Uwe Kleine-König, Dec 21, 2006
  5. Johannes SchindelinDec 21, 2006
  6. Santi BéjarDec 21, 2006
  7. Alexander LitvinovDec 21, 2006
  8. Jakub NarebskiDec 21, 2006
  9. Alexander LitvinovDec 21, 2006
  10. Jakub NarebskiDec 21, 2006
  11. Uwe Kleine-KönigDec 21, 2006
  12. Junio C HamanoDec 21, 2006
  13. Nicolas PitreDec 21, 2006
  14. Uwe Kleine-KönigDec 21, 2006
  15. Alexander LitvinovDec 21, 2006
  16. Johannes SchindelinDec 22, 2006
  17. Uwe Kleine-KönigDec 22, 2006
  18. Uwe Kleine-KönigDec 22, 2006
  19. Nicolas PitreDec 22, 2006
  20. Junio C HamanoDec 22, 2006
  21. 1/2 libgit.a: add some UTF-8 handling functionsJohannes Schindelin, Dec 22, 2006
  22. Junio C HamanoDec 22, 2006
  23. Johannes SchindelinDec 22, 2006
  24. Junio C HamanoDec 22, 2006
  25. Johannes SchindelinDec 22, 2006
  26. Junio C HamanoDec 22, 2006
  27. Alexander LitvinovDec 25, 2006
  28. Uwe Kleine-KönigDec 22, 2006
  29. Uwe Kleine-KönigDec 22, 2006
  30. Johannes SchindelinDec 22, 2006
  31. Johannes SchindelinDec 22, 2006
  32. Uwe Kleine-KönigDec 23, 2006
  33. Johannes SchindelinDec 23, 2006
  34. warn non utf-8 commit log messages.Junio C Hamano, Dec 23, 2006
  35. Johannes SchindelinDec 23, 2006
  36. 2/2 git-commit-tree: if i18n.commitencoding is utf-8 (default), check itJohannes Schindelin, Dec 22, 2006
  37. Junio C HamanoDec 22, 2006
  38. Johannes SchindelinDec 22, 2006
  39. 3/2 Wrap lines in shortlogJohannes Schindelin, Dec 22, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.