libwebsockets
Lightweight C library for HTML5 websockets
Urlencode and Urldecode

Functions

LWS_VISIBLE LWS_EXTERN const char * lws_urlencode (char *escaped, const char *string, int len)
 
LWS_VISIBLE LWS_EXTERN int lws_urldecode (char *string, const char *escaped, int len)
 

Detailed Description

HTML chunked Substitution

APIs for receiving chunks of text, replacing a set of variable names via a callback, and then prepending and appending HTML chunked encoding headers.

Function Documentation

◆ lws_urldecode()

LWS_VISIBLE LWS_EXTERN int lws_urldecode ( char *  string,
const char *  escaped,
int  len 
)

#include <lib/libwebsockets.h>

lws_urldecode() - like strncpy but with urldecoding

Parameters
stringoutput buffer
escapedinput buffer ('\0' terminated)
lenoutput buffer max length

This is only useful for '\0' terminated strings

Since urldecoding only shrinks the output string, it is possible to do it in-place, ie, string == escaped

Returns 0 if completed OK or nonzero for urldecode violation (non-hex chars where hex required, etc)

◆ lws_urlencode()

LWS_VISIBLE LWS_EXTERN const char* lws_urlencode ( char *  escaped,
const char *  string,
int  len 
)

#include <lib/libwebsockets.h>

lws_urlencode() - like strncpy but with urlencoding

Parameters
escapedoutput buffer
stringinput buffer ('/0' terminated)
lenoutput buffer max length

Because urlencoding expands the output string, it's not possible to do it in-place, ie, with escaped == string