Evas textblock: Added support for numeric escape sequences.

Patch by Raoul Hecky.

SVN revision: 59780
This commit is contained in:
Tom Hacohen 2011-05-29 11:47:53 +00:00
parent 422d9358bf
commit dbe7a9800e
2 changed files with 52 additions and 10 deletions

View File

@ -380,3 +380,7 @@
* Font-engine: Conform to the API changes in Harfbuzz 0.6.0
2011-05-29 Raoul Hecky
* Textblock: Added support for numeric escape codes. e.g "<".

View File

@ -4591,18 +4591,56 @@ _escaped_char_match(const char *s, int *adv)
static inline const char *
_escaped_char_get(const char *s, const char *s_end)
{
const char *map_itr, *map_end;
map_itr = escape_strings;
map_end = map_itr + sizeof(escape_strings);
while (map_itr < map_end)
/* Handle numeric escape codes. */
if (s[1] == '#')
{
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);
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 "&#" */
if (tolower(*s) == 'x')
{
s++;
base = 16;
}
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
{
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;
}