1 /* $Id: entity.c,v 1.7 2003/09/24 18:48:59 ukai Exp $ */
18 static char *alt_latin1[ 96 ] = {
19 NBSP, "!", "-c-", "-L-", "CUR", "=Y=", "|", "S:",
20 "\"", "(C)", "-a", "<<", "NOT", "-", "(R)", "-",
21 "DEG", "+-", "^2", "^3", "'", "u", "P:", ".",
22 ",", "^1", "-o", ">>", "1/4", "1/2", "3/4", "?",
23 "A`", "A'", "A^", "A~", "A:", "AA", "AE", "C,",
24 "E`", "E'", "E^", "E:", "I`", "I'", "I^", "I:",
25 "D-", "N~", "O`", "O'", "O^", "O~", "O:", "x",
26 "O/", "U`", "U'", "U^", "U:", "Y'", "TH", "ss",
27 "a`", "a'", "a^", "a~", "a:", "aa", "ae", "c,",
28 "e`", "e'", "e^", "e:", "i`", "i'", "i^", "i:",
29 "d-", "n~", "o`", "o'", "o^", "o~", "o:", "-:",
30 "o/", "u`", "u'", "u^", "u:", "y'", "th", "y:"
35 conv_entity(unsigned int c)
39 if (c < 0x20) /* C0 */
41 if (c < 0x7f) /* ASCII */
42 return Strnew_charp_n(&b, 1)->ptr;
43 if (c < 0xa0) /* DEL, C1 */
47 if (c < 0x100) { /* Latin1 (ISO 8859-1) */
49 return alt_latin1[c - 0xa0];
51 return wc_conv_n(&b, 1, WC_CES_ISO_8859_1, InnerCharset)->ptr;
53 return Strnew_charp_n(&b, 1)->ptr;
58 if (c <= WC_C_UCS4_END) { /* Unicode */
60 wc_ucs_to_utf8(c, utf8);
61 return wc_conv((char *)utf8, WC_CES_UTF_8, InnerCharset)->ptr;