Re: GLib substr function
- From: Christian Dywan <christian imendio com>
- To: gtk-devel-list gnome org
- Subject: Re: GLib substr function
- Date: Fri, 10 Apr 2009 18:34:10 +0200
Am Fri, 10 Apr 2009 16:49:43 +0200
schrieb b0unc3 <daniele maio gmail com>:
> 2009/4/10 Nelson Benítez León <nbenitezl gmail com>
>
> > 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).
>
>
> First of all thanks to everyone who replayed.
> The implementation using g_srtndup looks ok.
>
> I was wondering why not to add a so simple example in the official
> docs (maybe in the g_strndup explanation).
Hey,
the reason is simple. This is entirely up to the programming language
and not at all Glib specific. If you want to learn more about C you
should look for a good C (online) book.
Regards,
Christian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]