/* $Header: /home/agc/src/libutf-2.10/RCS/utf.h,v 1.4 1997/03/14 16:27:18 agc Exp $ */ /* * Copyright © 1996-1997 Alistair G. Crooks. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Alistair G. Crooks. * 4. The name of the author may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef UTF_H_ #define UTF_H_ /* a Unicode character */ typedef unsigned short Rune; enum { UTFmax = 3, /* maximum bytes per Rune */ Runesync = 0x21, /* can't represent part of a UTF sequence */ Runeself = 0xa0, /* rune and UTF sequences are the same */ Runeerror = 0x80 /* decoding error in UTF */ }; /* prototypes */ int runetochar(char *cp, Rune *rp); int chartorune(Rune *rp, char *cp); int runelen(long r); int fullrune(char *cp, int n); int utflen(char *s); int utfbytes(char *s); char *utfrune(char *cp, long r); char *utfrrune(char *cp, long r); char *utfutf(char *big, char *little); int utfcmp(char *s1, char *s2); int utfncmp(char *s1, char *s2, int rc); int utfspan(char *s1, char *s2, int *rc); int utfcspan(char *s1, char *s2, int *rc); int priorrune(Rune *rp, char *s); char *utffindrune(char *s, char *charset); int runeutfncmp(Rune *rp, char *up, int n); char *utfcpy(char *dst, char *src); char *utfncpy(char *dst, char *src, int nbytes); int utf_snprintf(char *buf, int size, char *fmt, ...); int utfnlen(char *s, int n); char *utfcat(char *src, char *append); char *utfncat(char *src, char *append, int slen); int AsciiToNumber(char *s, int cc, int base); int CharToNum(char *cp); int CharToDec(unsigned char ch); int UNICODE_isdigit(Rune ch); int UNICODE_isletter(Rune ch); int UNICODE_IsIdent(Rune ch); Rune UNICODE_tolower(Rune ch); Rune UNICODE_toupper(Rune ch); int UNICODE_isalpha(Rune c); int UNICODE_isupper(Rune c); int UNICODE_islower(Rune c); int UNICODE_isnumber(Rune c); int UNICODE_isxdigit(Rune c); int UNICODE_isalnum(Rune c); int UNICODE_isspace(Rune c); int UNICODE_isblank(Rune c); int UNICODE_ispunct(Rune c); int UNICODE_isprint(Rune c); int UNICODE_iscntrl(Rune c); int UNICODE_isascii(Rune c); int UNICODE_isgraph(Rune c); int UNICODE_InRange(Rune first, Rune last, Rune ch); int UNICODE_mixed_strncmp(Rune *s1, char *s2, int n); int UNICODE_strcasecmp(Rune *s1, Rune *s2); int UNICODE_strlen(Rune *s); Rune *UNICODE_strcat(Rune *s1, Rune *s2); Rune *UNICODE_strchr(Rune *s, Rune ch); int UNICODE_strcmp(Rune *s1, Rune *s2); Rune *UNICODE_strcpy(Rune *to, Rune *from); int UNICODE_strcspn(Rune *s1, Rune *s2); Rune *UNICODE_strdup(Rune *s); int UNICODE_strncasecmp(Rune *s1, Rune *s2, int n); Rune *UNICODE_strncat(Rune *s1, Rune *s2, int n); int UNICODE_strncmp(Rune *s1, Rune *s2, int n); Rune *UNICODE_strncpy(Rune *to, Rune *from, int n); Rune *UNICODE_strpbrk(Rune *s1, Rune *s2); Rune *UNICODE_strrchr(Rune *s, Rune ch); int UNICODE_strspn(Rune *s1, Rune *s2); Rune *UNICODE_strstr(Rune *s, Rune *find); int urecollseq(char *collseq); int utflangcmp(char *s1, char *s2, char *lang, int icase); #endif /* ! UTF_H_ */