summaryrefslogtreecommitdiffstats
path: root/unicode/unicode_htmlent.c
diff options
context:
space:
mode:
authorSam Varshavchik2015-07-26 22:48:53 -0400
committerSam Varshavchik2015-07-26 22:48:53 -0400
commit9827d1dcf469fd4d715ad115a573c7c00218dd01 (patch)
tree1c0079fcd1c628f5253a87a9d34e75e209a70ca7 /unicode/unicode_htmlent.c
parentf1bd3147e4df1bda680a7ecbfeca5699eed7788f (diff)
downloadcourier-libs-9827d1dcf469fd4d715ad115a573c7c00218dd01.tar.bz2
courier-unicode: minor tweaks.
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;