>>> substring (GString *str, int index, int len)
>>> {
>>> return g_string_new_len (str->str, index, MIN (str->len - index, len));
>>> }
>> I was wondering why not to add a so simple example in the official docs
>> (maybe in the g_strndup explanation).
> Maybe because it's completely wrong for UTF-8 strings?
Why, then, doesn't glib come with a completely right implementation?
Basic string operations like sub-string and string replace, should be part of glib, and for every string format that glib supports (including plain ASCII). Especially when it's so obvious that a lot of people still do it incorrectly.