1 /* 2 * The authors of this software are Rob Pike and Ken Thompson. 3 * Copyright (c) 2002 by Lucent Technologies. 4 * Permission to use, copy, modify, and distribute this software for any 5 * purpose without fee is hereby granted, provided that this entire notice 6 * is included in all copies of any software which is or includes a copy 7 * or modification of this software and in all copies of the supporting 8 * documentation for such software. 9 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE 11 * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 */ 14 #ifndef js_utf_h 15 #define js_utf_h 16 17 typedef int Rune; /* 32 bits */ 18 19 #define chartorune jsU_chartorune 20 #define runetochar jsU_runetochar 21 #define runelen jsU_runelen 22 #define utflen jsU_utflen 23 24 #define isalpharune jsU_isalpharune 25 #define islowerrune jsU_islowerrune 26 #define isupperrune jsU_isupperrune 27 #define tolowerrune jsU_tolowerrune 28 #define toupperrune jsU_toupperrune 29 30 enum 31 { 32 UTFmax = 4, /* maximum bytes per rune */ 33 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */ 34 Runeself = 0x80, /* rune and UTF sequences are the same (<) */ 35 Runeerror = 0xFFFD, /* decoding error in UTF */ 36 Runemax = 0x10FFFF, /* maximum rune value */ 37 }; 38 39 int chartorune(Rune *rune, const char *str); 40 int runetochar(char *str, const Rune *rune); 41 int runelen(int c); 42 int utflen(const char *s); 43 44 int isalpharune(Rune c); 45 int islowerrune(Rune c); 46 int isupperrune(Rune c); 47 Rune tolowerrune(Rune c); 48 Rune toupperrune(Rune c); 49 50 #endif 51