GLib substr function

2009-04-10 Thread b0unc3
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 ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list

Re: GLib substr function

2009-04-10 Thread Christian Dywan
Am Fri, 10 Apr 2009 12:45:39 +0200 schrieb b0unc3 daniele.m...@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 Hey b0unc3, no, there isn't. Either you use a higher level language which

Re: GLib substr function

2009-04-10 Thread Valerio Messina
b0unc3 wrote: there is any implementation of a substr function in GLib ? I mean : string = hello world g_*substr*(string,2,6) output = llo w probably not, maybe because is something too simple like: g_*strndup* (string+start, end-start+1); Valerio

Re: GLib substr function

2009-04-10 Thread Tim-Philipp Müller
On Fri, 2009-04-10 at 12:45 +0200, b0unc3 wrote: there is any implementation of a substr function in GLib ? I mean : string = hello world g_*substr*(string,2,6) output = llo w substr = g_strndup (string + offset, len); ... g_free (substr); should do the trick (assuming that offset

Re: GLib substr function

2009-04-10 Thread b0unc3
2009/4/10 Nelson Benítez León nbenit...@gmail.com 2009/4/10 b0unc3 daniele.m...@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,

Re: GLib substr function

2009-04-10 Thread Christian Dywan
Am Fri, 10 Apr 2009 16:49:43 +0200 schrieb b0unc3 daniele.m...@gmail.com: 2009/4/10 Nelson Benítez León nbenit...@gmail.com 2009/4/10 b0unc3 daniele.m...@gmail.com: Hi all, there is any implementation of a substr function in GLib ? I mean : string = hello world

Re: GLib substr function

2009-04-10 Thread Stef Walter
b0unc3 wrote: 2009/4/10 Nelson Benítez León nbenit...@gmail.com Another way, substring (GString *str, int index, int len) { return g_string_new_len (str-str, index, MIN (str-len - index, len)); } snip First of all thanks to everyone who replayed. The implementation using g_srtndup

Re: GLib substr function

2009-04-10 Thread Freddie Unpenstein
From: Stef Walter, Date: 11/04/2009 03:45, Wrote: 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