diff options
| author | Sam Varshavchik | 2015-07-31 06:35:40 -0400 |
|---|---|---|
| committer | Sam Varshavchik | 2015-07-31 06:36:57 -0400 |
| commit | 228f4c614680f27acceb807074857c01c753e100 (patch) | |
| tree | 229ea4acc6da4cb5a14203dba3714b9373dad1eb /unicode/unicode_htmlent.c | |
| parent | e6d23dfcf40f073a1e5b267cb1333365507a9781 (diff) | |
| parent | f2db754527106a53afde3acfae7f24844755face (diff) | |
| download | courier-libs-228f4c614680f27acceb807074857c01c753e100.tar.bz2 | |
Merge branch 'master'.
Diffstat (limited to 'unicode/unicode_htmlent.c')
| -rw-r--r-- | unicode/unicode_htmlent.c | 34 |
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; |
