gchar * g_utf8_offset_to_pointer (const gchar *str, glong offset) { const gchar *s = str; #define FOUR_SINGLEBYTE_CHARS(p) (*(guint32 *)(p) & 0xc0c0c0c0) == 0 while (offset) { if (offset > 4 && FOUR_SINGLEBYTE_CHARS (s)) { s += 4; offset -= 4; } else { --offset; s = g_utf8_next_char (s); } } return (gchar *)s; }