Home
Highly Reusable Software By activity User Interface Text Strings Math Processing
Stored Data
Communications
Hard World File System
|
#License - #Source code - #Example Use -
#include <librock/html.h> char * librock_HTTP_astrcatUrlEncode( char **ppasz, /* librock_astring */ const char *pString,int cbString)
If you want '/' to appear literally, then handle it separately as in the example use below.
Returns *ppasz.
Typical use is
#ifdef librock_TYPICAL_USE_HTTP_astrcatUrlEncode char *asz = 0; librock_astrcat(&asz,"/"); librock_HTTP_astrcatUrlEncode(&asz,"path",4); librock_astrcat(&asz,"/"); librock_HTTP_astrcatUrlEncode(&asz,"to resource",11); printf("GET %s HTTP/1.0\n",asz); librock_astrfree(&asz); #endifTo construct a URL encoded Query String, see librock_HTTP_SetFieldUrlEncoded, or use code similar to the following:
#ifdef librock_TYPICAL_USE_2_HTTP_astrcatUrlEncode char *asz = 0; librock_HTTP_astrcatUrlEncode(&asz,"field name",10); librock_astrcat(&asz,"="); librock_HTTP_astrcatUrlEncode(&asz,"/field value/",13); librock_astrcat(&asz,"&"); librock_HTTP_astrcatUrlEncode(&asz,"field name 2",12); librock_astrcat(&asz,"="); librock_HTTP_astrcatUrlEncode(&asz,"/field value 2/",15); printf("GET /query.cgi?%s HTTP/1.0\n",asz); librock_astrfree(&asz); #endifIf you want to construct a URL-encoded Query String for placing inside an HREF attribute, then build up the query string, then use librock_astrcatValueEncode. (If you have difficulty thinking of the order, remember that any encoding must be done in the reverse order it will be decoded. The browser will decode the value first, so that means value encoding must be done last.)
Code is similar to the following:
#ifdef librock_TYPICAL_USE_3_HTTP_astrcatUrlEncode char *asz = 0; char *asz2 = 0; librock_HTTP_astrcatUrlEncode(&asz,"field",5); librock_astrcat(&asz,"="); librock_HTTP_astrcatUrlEncode(&asz,"value",5); librock_astrcat(&asz,"&"); librock_HTTP_astrcatUrlEncode(&asz,"field",5); librock_astrcat(&asz,"="); librock_HTTP_astrcatUrlEncode(&asz,"value",5); librock_HTML_astrcatValueEncode(&asz2,asz,strlen(asz)); printf("<A HREF=\"%s\">\n",asz2); librock_astrfree(&asz); librock_astrfree(&asz2); #endifSee also librock_HTTP_astrSetFieldUrlEncode(), if field names are unique in the query string.
*/USES
isalnum() librock_chisel _usesrc "text/astring.c" librock_astrn0cat()LICENSE
Copyright 1998-2002 Forrest J. Cavalier III, http://www.mibsoftware.com Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block. License text in <librock/license/librock.txt> librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45Source Code
./spec/infotool/www/html.c (implementation, plus source of this manual page)Tests and Supported Platform Types
This is a representative sample. Librock code is highly portable. For a particular platform not reported here, request paid supportlibrock_HTTP_astrcatUrlEncode passed tests in thtml (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_HTTP_astrcatUrlEncode passed tests in thtml (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
This software is part of Librock
Rapid reuse, without rework.
Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)
Want to help? We welcome comments, patches. -- Need help? Request paid support.