Core/Data/WebHelpers/escape.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <WString.h>
4 
10 unsigned uri_escape_len(const char* s, size_t len);
11 
12 static inline unsigned uri_escape_len(const String& str)
13 {
14  return uri_escape_len(str.c_str(), str.length());
15 }
16 
26 char* uri_escape(char* dest, size_t dest_len, const char* src, int src_len);
27 
36 char* uri_unescape(char* dest, size_t dest_len, const char* src, int src_len);
37 
38 unsigned html_escape_len(const char* s, size_t len);
39 void html_escape(char* dest, size_t len, const char* s);
40 
47 
54 String uri_escape(const char* src, int src_len);
55 
56 static inline String uri_escape(const String& src)
57 {
58  return src ? uri_escape(src.c_str(), src.length()) : src;
59 }
60 
67 
71 static inline String uri_unescape(const String& str)
72 {
73  String ret = str;
75  return ret;
76 }
char * uri_escape(char *dest, size_t dest_len, const char *src, int src_len)
Escape text.
unsigned uri_escape_len(const char *s, size_t len)
Obtain number of characters required to escape the given text.
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.
unsigned html_escape_len(const char *s, size_t len)
char * uri_unescape(char *dest, size_t dest_len, const char *src, int src_len)
unescape text
The String class.
Definition: WString.h:137
const char * c_str() const
Get a constant (un-modifiable) pointer to String content.
Definition: WString.h:616
size_t length(void) const
Obtain the String length in characters, excluding NUL terminator.
Definition: WString.h:243
#define str(s)
Definition: testrunner.h:124