Re: GLib substr function
- From: Nelson Benítez León <nbenitezl gmail com>
- To: b0unc3 <daniele maio gmail com>
- Cc: gtk-devel-list gnome org
- Subject: Re: GLib substr function
- Date: Fri, 10 Apr 2009 14:30:16 +0100
2009/4/10 b0unc3 <daniele maio gmail com>:
> Hi all,
>
> there is any implementation of a substr function in GLib ?
>
> I mean :
> string = "hello world"
> g_*substr*(string,2,6)
> output = llo w
Another way,
substring (GString *str, int index, int len)
{
return g_string_new_len (str->str, index, MIN (str->len - index, len));
}
taken from http://bugzilla.gnome.org/show_bug.cgi?id=109286#c2 .
I personally would like that glib provide those small but useful
string functions (like other high level languages do), for example,
glib doesn't provide a simple function to replace strings, like this
one written by Tim in
http://bugzilla.gnome.org/show_bug.cgi?id=65987#c2 ,
gchar *
g_strreplace (const gchar *string,
const gchar *search,
const gchar *replacement)
Instead you currently have to use gregex to replace some simple
strings (where no regex are involved).
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]