{
Termio *sd = evas_object_smart_data_get(obj);
Eina_Strbuf *sb;
- char *s, txt[8];
+ char *s;
int x, y;
if (!sd) return NULL;
else if (cells[x].att.newline)
{
last0 = -1;
- eina_strbuf_append(sb, "\n");
+ eina_strbuf_append_char(sb, '\n');
break;
}
else if (cells[x].att.tab)
{
- eina_strbuf_append(sb, "\t");
+ eina_strbuf_append_char(sb, '\t');
x = ((x + 8) / 8) * 8;
x--;
}
else
{
+ char txt[8];
+ int txtlen;
+
if (last0 >= 0)
{
v = x - last0 - 1;
last0 = -1;
while (v >= 0)
{
- eina_strbuf_append(sb, " ");
+ eina_strbuf_append_char(sb, ' ');
v--;
}
if (x == (w - 1))
{
if (!cells[x].att.autowrapped)
- eina_strbuf_append(sb, "\n");
+ eina_strbuf_append_char(sb, '\n');
}
}
- glyph_to_utf8(cells[x].glyph, txt);
- eina_strbuf_append(sb, txt);
+ txtlen = glyph_to_utf8(cells[x].glyph, txt);
+ if (txtlen > 0)
+ eina_strbuf_append_length(sb, txt, txtlen);
}
}
if (last0 >= 0)
{
- eina_strbuf_append(sb, "\n");
+ eina_strbuf_append_char(sb, '\n');
}
}
#include "utf8.h"
-void
+int
glyph_to_utf8(int g, char *txt)
{
if (g < (1 << (7)))
{ // 0xxxxxxx
txt[0] = g & 0x7f;
txt[1] = 0;
+ return 1;
}
else if (g < (1 << (5 + 6)))
{ // 110xxxxx 10xxxxxx
txt[0] = 0xc0 | ((g >> 6) & 0x1f);
txt[1] = 0x80 | ((g ) & 0x3f);
txt[2] = 0;
+ return 2;
}
else if (g < (1 << (4 + 6 + 6)))
{ // 1110xxxx 10xxxxxx 10xxxxxx
txt[1] = 0x80 | ((g >> 6 ) & 0x3f);
txt[2] = 0x80 | ((g ) & 0x3f);
txt[3] = 0;
+ return 3;
}
else if (g < (1 << (3 + 6 + 6 + 6)))
{ // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
txt[2] = 0x80 | ((g >> 6 ) & 0x3f);
txt[3] = 0x80 | ((g ) & 0x3f);
txt[4] = 0;
+ return 4;
}
else if (g < (1 << (2 + 6 + 6 + 6 + 6)))
{ // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
txt[3] = 0x80 | ((g >> 6 ) & 0x3f);
txt[4] = 0x80 | ((g ) & 0x3f);
txt[5] = 0;
+ return 5;
}
else if (g < (1 << (1 + 6 + 6 + 6 + 6 + 6)))
{ // 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
txt[4] = 0x80 | ((g >> 6 ) & 0x3f);
txt[5] = 0x80 | ((g ) & 0x3f);
txt[6] = 0;
+ return 6;
}
else
{ // error - cant encode this in utf8
txt[0] = 0;
+ return 0;
}
}
-