blob: eb5ea42a8fb35a599cf3b1be760a3142fc5f7f34 [file] [log] [blame]
rscf7012582003-11-25 01:40:27 +00001#ifndef _UTF_H_
2#define _UTF_H_ 1
3#if defined(__cplusplus)
4extern "C" {
5#endif
rscb2cfc4e2003-09-30 17:47:41 +00006
7typedef unsigned short Rune; /* 16 bits */
8
9enum
10{
11 UTFmax = 3, /* maximum bytes per rune */
12 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
13 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
rsccbeb0b22006-04-01 19:24:03 +000014 Runeerror = 0xFFFD /* decoding error in UTF */
rscb2cfc4e2003-09-30 17:47:41 +000015};
16
rsc8bbb2f62004-12-25 22:00:00 +000017/* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/utf/?*.c | grep -v static |grep -v __ */
18int chartorune(Rune *rune, char *str);
19int fullrune(char *str, int n);
20int isalpharune(Rune c);
21int islowerrune(Rune c);
22int isspacerune(Rune c);
23int istitlerune(Rune c);
24int isupperrune(Rune c);
25int runelen(long c);
26int runenlen(Rune *r, int nrune);
27Rune* runestrcat(Rune *s1, Rune *s2);
28Rune* runestrchr(Rune *s, Rune c);
29int runestrcmp(Rune *s1, Rune *s2);
30Rune* runestrcpy(Rune *s1, Rune *s2);
31Rune* runestrdup(Rune *s) ;
32Rune* runestrecpy(Rune *s1, Rune *es1, Rune *s2);
33long runestrlen(Rune *s);
34Rune* runestrncat(Rune *s1, Rune *s2, long n);
35int runestrncmp(Rune *s1, Rune *s2, long n);
36Rune* runestrncpy(Rune *s1, Rune *s2, long n);
37Rune* runestrrchr(Rune *s, Rune c);
38Rune* runestrstr(Rune *s1, Rune *s2);
39int runetochar(char *str, Rune *rune);
40Rune tolowerrune(Rune c);
41Rune totitlerune(Rune c);
42Rune toupperrune(Rune c);
43char* utfecpy(char *to, char *e, char *from);
44int utflen(char *s);
45int utfnlen(char *s, long m);
46char* utfrrune(char *s, long c);
47char* utfrune(char *s, long c);
48char* utfutf(char *s1, char *s2);
rscb2cfc4e2003-09-30 17:47:41 +000049
rscf7012582003-11-25 01:40:27 +000050#if defined(__cplusplus)
51}
52#endif
rscb2cfc4e2003-09-30 17:47:41 +000053#endif