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