Re: URL encoding feature

Ahmad Baitalmal wrote:">I've  ran into this problem a few times so I decided to fix it and send it in.  I though something like this would be found in glib, but I didn't find it  anywhere. gtkhtml uses libwww and it's a big mess for what I wanted to do. 

gchar* url_encode( gchar* source )

source :    The raw URL string.
returns:    A new allocated URL encoded string, must free with g_free when done.

This function follows RFC 2396 (Query Component)

tts = g_strdup(" Bin Fernas, huh?" );
tts = url_encode( tts );
g_print("%s\n", tts);
g_free( tts );

This would be neat in glib string utilities. The files attached are url_encode.h and url_encode.c

Have fun,


The example above is a bit misleading. You should not encode the WHOLE url. Just the text part. The best web server on the planet (a.k.a. Apache) will not response if you send spaces in query variables. So you must encode the variable values only "Abbas Bin Fernas, huh?".

Take care,

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]