libutf

UTF-8 library
git clone git://git.suckless.org/libutf
Log | Files | Refs | README | LICENSE

commit ea636e77ab27c87482a51ee8176e150d3e92003d
parent e04271bb0e4b0cfeabed0ecbed7155666d1468c9
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Thu, 19 Apr 2012 17:41:41 +0100

add enum Runeself, Runemax
Diffstat:
utf.c | 6+++---
utf.h | 6++++--
2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/utf.c b/utf.c @@ -125,7 +125,7 @@ runelen(Rune r) return 2; else if(r <= 0xFFFF) return 3; - else if(r <= 0x10FFFF) + else if(r <= Runemax) return 4; else return 0; /* error */ @@ -222,7 +222,7 @@ utfnlen(const char *s, size_t len) char * utfrune(const char *s, Rune r) { - if(r <= 0x7F) { + if(r < Runeself) { return strchr(s, r); } else if(r == Runeerror) { @@ -259,7 +259,7 @@ utfrrune(const char *s, Rune r) Rune r0; int n; - if(r <= 0x7F) + if(r < Runeself) return strrchr(s, r); for(; *s != '\0'; s += n) { diff --git a/utf.h b/utf.h @@ -7,8 +7,10 @@ typedef unsigned int Rune; enum { - UTFmax = 6, - Runeerror = 0xFFFD + UTFmax = 6, /* maximum bytes per rune */ + Runeself = 0x80, /* rune and utf are equal (<) */ + Runeerror = 0xFFFD, /* decoding error in utf */ + Runemax = 0x10FFFF /* maximum rune value */ }; int runetochar(char *, Rune *);