Clone this repo:

Branches

Tags

  1. ee5074d Merge pull request #12 from finnoleary/fix-missing-funcdefs by Connor Lane Smith · 2 years, 2 months ago master
  2. c7812d1 Add missing function definitions (utfecpy, runestrecpy) by Finn O'leary · 2 years, 2 months ago
  3. ff4c606 update licence by Connor Lane Smith · 4 years, 2 months ago
  4. b17614b add .gitattributes for C header files by Connor Lane Smith · 4 years, 3 months ago
  5. 60a0b75 Merge pull request #10 from richardipsum/awk-avoid-length by Connor Lane Smith · 4 years, 3 months ago

libutf

Build Status

This is a C89 UTF-8 library, with an API compatible with that of Plan 9's libutf, but with a number of improvements:

  • Support for runes beyond the Basic Multilingual Plane.
  • utflen and utfnlen cannot overflow on 32- or 64-bit machines.
  • chartorune treats all invalid codepoints as though Runeerror.
  • fullrune, utfecpy, and utfnlen do not overestimate the length of malformed runes.
  • An extra function, charntorune(p,s,n), equivalent to fullrune(s,n) ? chartorune(p,s) : 0.
  • Runeerror may be set to an alternative replacement value, such as -1, to be used instead of U+FFFD.

Differences to be aware of:

  • UTFmax is 6, though runetochar will never write more than 4 bytes. Plan 9's UTFmax is 3.
  • chartorune may consume multiple bytes for each illegal rune. Plan 9 always consumes 1.
  • runelen and runetochar return 0 if the rune is too large to print. Plan 9 erroneously returns UTFmax.