From 9827d1dcf469fd4d715ad115a573c7c00218dd01 Mon Sep 17 00:00:00 2001 From: Sam Varshavchik Date: Sun, 26 Jul 2015 22:48:53 -0400 Subject: courier-unicode: minor tweaks. --- unicode/unicode_htmlent.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'unicode/unicode_htmlent.c') diff --git a/unicode/unicode_htmlent.c b/unicode/unicode_htmlent.c index c98f43d..b1111ce 100644 --- a/unicode/unicode_htmlent.c +++ b/unicode/unicode_htmlent.c @@ -44,10 +44,36 @@ static int compar(const void *key, const void *obj) unicode_char unicode_html40ent_lookup(const char *n) { - const struct i *ptr= - (const struct i *)bsearch(n, ii, - sizeof(ii)/sizeof(ii[0]), - sizeof(ii[0]), compar); + const struct i *ptr; + + if (*n == '#') + { + const char *p=n; + unicode_char uc; + char *endptr; + + ++p; + + if (*p == 'x' || *p == 'X') + { + if (*++p) + { + uc=strtoull(p, &endptr, 16); + + if (*endptr == 0) + return uc; + } + } + + uc=strtoull(p, &endptr, 10); + + if (*endptr == 0) + return uc; + } + + ptr=(const struct i *)bsearch(n, ii, + sizeof(ii)/sizeof(ii[0]), + sizeof(ii[0]), compar); if (ptr) return ptr->v; -- cgit v1.2.3