1 #ifndef EL__INTL_CHARSETS_H 2 #define EL__INTL_CHARSETS_H 3 4 typedef uint32_t unicode_val_T; 5 6 /* U+00A0 NO-BREAK SPACE. */ 7 #define UCS_NO_BREAK_SPACE ((unicode_val_T) 0x00A0) 8 9 /* U+00AD SOFT HYPHEN. */ 10 #define UCS_SOFT_HYPHEN ((unicode_val_T) 0x00AD) 11 12 /* UCS/Unicode replacement character. */ 13 #define UCS_NO_CHAR ((unicode_val_T) 0xFFFD) 14 15 /* replacement character. See u2cp(). */ 16 #define NBSP_CHAR ((unsigned char) 1) 17 #define NBSP_CHAR_STRING "\001" 18 19 struct conv_table { 20 int t; 21 union { 22 unsigned char *str; 23 struct conv_table *tbl; 24 } u; 25 }; 26 27 enum convert_string_mode { 28 CSM_DEFAULT, /* Convert any char. */ 29 CSM_QUERY, /* Special handling of '&' and '=' chars. */ 30 CSM_FORM, /* Special handling of '&' and '=' chars in forms. */ 31 CSM_NONE, /* Convert nothing. */ 32 }; 33 34 struct conv_table *get_translation_table(int, int); 35 unsigned char *get_entity_string(const unsigned char *str, const int strlen, int encoding); 36 37 /* The convert_string() name is also used by Samba (version 3.0.3), which 38 * provides libnss_wins.so.2, which is called somewhere inside 39 * _nss_wins_gethostbyname_r(). This name clash causes the elinks hostname 40 * lookup thread to crash so we need to rename the symbol. */ 41 /* Reported by Derek Poon and filed as bug 453 */ 42 #undef convert_string 43 #define convert_string convert_string_elinks 44 45 /* This routine converts a string from one charset to another according to the 46 * passed @convert_table, potentially also decoding SGML (HTML) entities along 47 * the way (according to @mode). It either returns dynamically allocated 48 * converted string of length @length, or if the @callback is non-NULL it calls 49 * it each few bytes instead and always returns NULL (@length is undefined). 50 * Note that it's ok not to care and pass NULL as @length. */ 51 unsigned char *convert_string(struct conv_table *convert_table, 52 unsigned char *chars, int charslen, int cp, 53 enum convert_string_mode mode, int *length, 54 void (*callback)(void *data, unsigned char *buf, int buflen), 55 void *callback_data); 56 57 int get_cp_index(const unsigned char *); 58 unsigned char *get_cp_name(int); 59 unsigned char *get_cp_mime_name(int); 60 int is_cp_special(int); 61 void free_conv_table(void); 62 unsigned char *cp2utf_8(int, int); 63 64 unsigned char *u2cp_(unicode_val_T, int, int no_nbsp_hack); 65 #define u2cp(u, to) u2cp_(u, to, 0) 66 #define u2cp_no_nbsp(u, to) u2cp_(u, to, 1) 67 68 void init_charsets_lookup(void); 69 void free_charsets_lookup(void); 70 71 #endif 72