From 77ad93e7a695a37c5dc40e442286aaa09fa39782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sat, 18 Oct 2014 13:38:22 +0000 Subject: [PATCH] [GB.GTK] * BUG: Correctly interpret "&#xxx;" HTML entities in rich text. [GB.GTK3] * BUG: Correctly interpret "&#xxx;" HTML entities in rich text. git-svn-id: svn://localhost/gambas/trunk@6560 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.gtk/src/gtools.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/gb.gtk/src/gtools.cpp b/gb.gtk/src/gtools.cpp index 42a002008..780bc1f94 100644 --- a/gb.gtk/src/gtools.cpp +++ b/gb.gtk/src/gtools.cpp @@ -1129,6 +1129,7 @@ char *gt_html_to_pango_string(const char *html, int len_html, bool newline_are_b const char *entity_start = ++p; int entity_len; int entity_unicode; + char *endptr; // if ((p_end - p) >= 6 && !strncasecmp(p, " ", 6)) // { @@ -1153,10 +1154,34 @@ char *gt_html_to_pango_string(const char *html, int len_html, bool newline_are_b } else { - const struct entity *e = kde_findEntity(entity_start, entity_len); - if (e) + entity_unicode = -1; + endptr = NULL; + errno = 0; + + if (*entity_start == '#') + { + if (entity_start[1] == 'x') + { + entity_unicode = strtol(&entity_start[2], &endptr, 16); + if (entity_unicode <= 0) + entity_unicode = -1; + } + else if (isdigit(entity_start[1])) + { + entity_unicode = strtol(&entity_start[1], &endptr, 10); + if (entity_unicode <= 0) + entity_unicode = -1; + } + } + else + { + const struct entity *e = kde_findEntity(entity_start, entity_len); + if (e) + entity_unicode = e->code; + } + + if (entity_unicode >= 0) { - entity_unicode = e->code; g_string_append_unichar(pango, entity_unicode); continue; }