escape.h File Reference
#include <user_config.h>
#include "WString.h"
Include dependency graph for escape.h:

Go to the source code of this file.

Functions

unsigned uri_escape_len (const char *s, size_t len)
 Obtain number of characters required to escape the given text. More...
 
static unsigned uri_escape_len (const String &str)
 
char * uri_escape (char *dest, size_t dest_len, const char *src, int src_len)
 Escape text. More...
 
char * uri_unescape (char *dest, size_t dest_len, const char *src, int src_len)
 unescape text More...
 
unsigned html_escape_len (const char *s, size_t len)
 
void html_escape (char *dest, size_t len, const char *s)
 
char * uri_unescape_inplace (char *str)
 Replace a nul-terminated string with its unescaped version. More...
 
String uri_escape (const char *src, int src_len)
 escape the given URI string More...
 
static String uri_escape (const String &src)
 
Stringuri_unescape_inplace (String &str)
 replace the given text by its unescaped version More...
 
static String uri_unescape (const String &str)
 return the unescaped version of a string More...
 

Function Documentation

◆ html_escape()

void html_escape ( char *  dest,
size_t  len,
const char *  s 
)

◆ html_escape_len()

unsigned html_escape_len ( const char *  s,
size_t  len 
)

◆ uri_escape() [1/3]

char* uri_escape ( char *  dest,
size_t  dest_len,
const char *  src,
int  src_len 
)

Escape text.

Parameters
destbuffer to store result
dest_lenavailable space in dest; requires +1 extra character for nul terminator, so at least uri_escape_len() + 1
srcsource text to escape
src_lennumber of characters in source
Return values
char*points to start of dest
Note
destination and source MUST be different buffers

◆ uri_escape() [2/3]

String uri_escape ( const char *  src,
int  src_len 
)

escape the given URI string

Parameters
src
src_len
Return values
Stringthe escaped string
Note
escaping may increase text size (but not always)

◆ uri_escape() [3/3]

static String uri_escape ( const String src)
inlinestatic

◆ uri_escape_len() [1/2]

unsigned uri_escape_len ( const char *  s,
size_t  len 
)

Obtain number of characters required to escape the given text.

Parameters
ssource text
lenNumber of characters in source text
Return values
unsignednumber of characters for output, NOT including nul terminator

◆ uri_escape_len() [2/2]

static unsigned uri_escape_len ( const String str)
inlinestatic

◆ uri_unescape() [1/2]

char* uri_unescape ( char *  dest,
size_t  dest_len,
const char *  src,
int  src_len 
)

unescape text

Parameters
destbuffer to store result
dest_lenavailable space in dest; requires +1 extra character for nul terminator
srcsource text to un-escape
src_lennumber of characters in source
Return values
char*points to start of dest
Note
destination and source may be the same buffer

◆ uri_unescape() [2/2]

static String uri_unescape ( const String str)
inlinestatic

return the unescaped version of a string

Return values
Stringunescaped string

◆ uri_unescape_inplace() [1/2]

char* uri_unescape_inplace ( char *  str)

Replace a nul-terminated string with its unescaped version.

Parameters
strthe string to un-escape
Return values
char*the result, a copy of str
Note
unescaped string is never longer than escaped version

◆ uri_unescape_inplace() [2/2]

String& uri_unescape_inplace ( String str)

replace the given text by its unescaped version

Parameters
strthe string to unescape
Return values
referenceto str, unescaped
Note
unescaped string is never longer than escaped version