Re: URL encoding feature



Ahmad Baitalmal wrote:
39B17942.3050906@bitbuilder.com">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. 
So

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)

Example:
tts = g_strdup("www.BitBuilder.com/query.php?text=Abbas Bin Fernas, huh?" );
tts = url_encode( tts );
g_print("%s\n", tts);
g_free( tts );
Result:
www.BitBuilder.com/query.php?text=Abbas%20Bin%20Fernas%2c%20huh%3f


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

Have fun,

-- 
Ahmadster
www.BitBuilder.com

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,
-- 
Ahmadster
www.BitBuilder.com


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