The qDecoder Project

qEncode.c File Reference

Encoding/decoding API. More…


Functions

Q_ENTRYqDecodeQueryString (Q_ENTRY *entry, const char *query, char equalchar, char sepchar, int *count)
 Parse URL encoded query string.
char * qEncodeUrl (const char *str)
 Encode string as URL encoded string.
char * qDecodeUrl (char *str)
 Parse URL encoded string.


Detailed Description

Encoding/decoding API.


Function Documentation

Q_ENTRY* qDecodeQueryString ( Q_ENTRY entry,
const char *  query,
char  equalchar,
char  sepchar,
int *  count 
)

Parse URL encoded query string.

Parameters:
entry a pointer of Q_ENTRY structure. NULL can be used
query URL encoded string
equalchar separater of key, value pair
sepchar separater of line
count if count is not NULL, a number of parsed entries are stored
Returns:
a pointer of Q_ENTRY if successful, otherwise returns NULL
 cont char query = "category=love&str=%C5%A5%B5%F0%C4%DA%B4%F5&sort=asc";
 Q_ENTRY entries = qDecodeQueryString(NULL, req->pszQueryString, '=', '&', NULL);
 printf("category = %sn", qEntryGetStr(entries, "category"));
 printf("str = %sn", qEntryGetStr(entries, "str"));
 printf("sort = %sn", qEntryGetStr(entries, "sort"));
 qEntryFree(entries);

char* qEncodeUrl ( const char *  str  ) 

Encode string as URL encoded string.

Parameters:
str a pointer of source string
Returns:
a malloced string pointer of URL encoded string in case of successful, otherwise returns NULL
 char encstr = qEncodeUrl("hello 'qDecoder' world");
 if(encstr != NULL) free(encstr);

char* qDecodeUrl ( char *  str  ) 

Parse URL encoded string.

Parameters:
str a pointer of URL encoded string
Returns:
a string pointer of str in case of successful, otherwise returns NULL
Note:
This modify str directly
 char str[256] = "hello%20%27qDecoder%27%20world";
 printf("Before : %sn", str);
 qDecodeUrl(str);
 printf("After  : %sn", str);


[Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference]