1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-29 01:45:34 +00:00

u2cp_: Make the no_nbsp_hack parameter an enum.

This is from attachment 279 of bug 811.  The change does not yet
affect any visible behaviour.
This commit is contained in:
Kalle Olavi Niemitalo 2006-10-02 00:33:41 +02:00 committed by Kalle Olavi Niemitalo
parent b880c3a682
commit 40b6edc69d
2 changed files with 20 additions and 6 deletions

View File

@ -164,7 +164,7 @@ static const unicode_val_T strange_chars[32] = {
#define is_cp_ptr_utf8(cp_ptr) ((cp_ptr)->aliases == aliases_utf8)
unsigned char *
u2cp_(unicode_val_T u, int to, int no_nbsp_hack)
u2cp_(unicode_val_T u, int to, enum nbsp_mode nbsp_mode)
{
int j;
int s;
@ -179,14 +179,17 @@ u2cp_(unicode_val_T u, int to, int no_nbsp_hack)
#endif /* CONFIG_UTF8 */
/* To mark non breaking spaces, we use a special char NBSP_CHAR. */
if (u == 0xa0) return no_nbsp_hack ? " " : NBSP_CHAR_STRING;
if (u == 0xa0) {
if (nbsp_mode == NBSP_MODE_HACK) return NBSP_CHAR_STRING;
else /* NBSP_MODE_ASCII */ return " ";
}
if (u == 0xad) return "";
if (u < 0xa0) {
unicode_val_T strange = strange_chars[u - 0x80];
if (!strange) return NULL;
return u2cp_(strange, to, no_nbsp_hack);
return u2cp_(strange, to, nbsp_mode);
}
if (u < 0xFFFF)

View File

@ -35,6 +35,17 @@ enum convert_string_mode {
CSM_NONE, /* Convert nothing. */
};
/* How to translate non-breaking spaces. */
enum nbsp_mode {
/* Convert to NBSP_CHAR. This lets the HTML renderer
* recognize nbsp even if the codepage doesn't support
* nbsp. (VISCII doesn't.) */
NBSP_MODE_HACK = 0,
/* Convert to normal ASCII space. */
NBSP_MODE_ASCII = 1
};
struct conv_table *get_translation_table(int, int);
unsigned char *get_entity_string(const unsigned char *str, const int strlen, int encoding);
@ -101,9 +112,9 @@ unicode_val_T cp_to_unicode(int, unsigned char **, unsigned char *);
unicode_val_T cp2u(int, unsigned char);
unsigned char *cp2utf8(int, int);
unsigned char *u2cp_(unicode_val_T, int, int no_nbsp_hack);
#define u2cp(u, to) u2cp_(u, to, 0)
#define u2cp_no_nbsp(u, to) u2cp_(u, to, 1)
unsigned char *u2cp_(unicode_val_T, int, enum nbsp_mode);
#define u2cp(u, to) u2cp_(u, to, NBSP_MODE_HACK)
#define u2cp_no_nbsp(u, to) u2cp_(u, to, NBSP_MODE_ASCII)
void init_charsets_lookup(void);
void free_charsets_lookup(void);