forked from enlightenment/efl
Evas textblock: Added support for numeric escape sequences.
Patch by Raoul Hecky. SVN revision: 59780
This commit is contained in:
parent
422d9358bf
commit
dbe7a9800e
|
@ -380,3 +380,7 @@
|
||||||
|
|
||||||
* Font-engine: Conform to the API changes in Harfbuzz 0.6.0
|
* 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 "<".
|
||||||
|
|
||||||
|
|
|
@ -4591,18 +4591,56 @@ _escaped_char_match(const char *s, int *adv)
|
||||||
static inline const char *
|
static inline const char *
|
||||||
_escaped_char_get(const char *s, const char *s_end)
|
_escaped_char_get(const char *s, const char *s_end)
|
||||||
{
|
{
|
||||||
const char *map_itr, *map_end;
|
/* Handle numeric escape codes. */
|
||||||
|
if (s[1] == '#')
|
||||||
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))
|
static char utf8_escape[7]; /* Support up to 6 bytes utf8 */
|
||||||
return map_itr;
|
char ustr[10];
|
||||||
if (map_itr < map_end)
|
Eina_Unicode uchar[2] = { 0, 0 };
|
||||||
_escaped_advance_after_end_of_string(&map_itr);
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue