summaryrefslogtreecommitdiffstats
path: root/unicode/unicode_htmlent.c
diff options
context:
space:
mode:
Diffstat (limited to 'unicode/unicode_htmlent.c')
-rw-r--r--unicode/unicode_htmlent.c34
1 files changed, 30 insertions, 4 deletions
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;