static inline const char *
_escaped_char_get(const char *s, const char *s_end)
{
- const char *map_itr, *map_end;
+ /* Handle numeric escape codes. */
+ if (s[1] == '#')
+ {
+ static char utf8_escape[7]; /* Support up to 6 bytes utf8 */
+ char ustr[10];
+ Eina_Unicode uchar[2] = { 0, 0 };
+ char *utf8_char;
+ size_t len = 0;
+ int base = 10;
+ s += 2; /* Skip "&#" */
- map_itr = escape_strings;
- map_end = map_itr + sizeof(escape_strings);
+ if (tolower(*s) == 'x')
+ {
+ s++;
+ base = 16;
+ }
- while (map_itr < map_end)
+ len = s_end - s;
+ if (len >= sizeof(ustr) + 1)
+ len = sizeof(ustr);
+
+ memcpy(ustr, s, len);
+ ustr[len] = '\0';
+ uchar[0] = strtol(ustr, NULL, base);
+
+ if (uchar[0] == 0)
+ return NULL;
+
+ utf8_char = eina_unicode_unicode_to_utf8(uchar, NULL);
+ strcpy(utf8_escape, utf8_char);
+ free(utf8_char);
+
+ return utf8_escape;
+ }
+ else
{
- if (_escaped_is_eq_and_advance(s, s_end, &map_itr, map_end))
- return map_itr;
- if (map_itr < map_end)
- _escaped_advance_after_end_of_string(&map_itr);
+ const char *map_itr, *map_end;
+
+ map_itr = escape_strings;
+ map_end = map_itr + sizeof(escape_strings);
+
+ while (map_itr < map_end)
+ {
+ if (_escaped_is_eq_and_advance(s, s_end, &map_itr, map_end))
+ return map_itr;
+ if (map_itr < map_end)
+ _escaped_advance_after_end_of_string(&map_itr);
+ }
}
+
return NULL;
}