Core/Data/WebHelpers/escape.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <user_config.h>
4 #include "WString.h"
5 
11 unsigned uri_escape_len(const char* s, size_t len);
12 
13 static inline unsigned uri_escape_len(const String& str)
14 {
15  return uri_escape_len(str.c_str(), str.length());
16 }
17 
27 char* uri_escape(char* dest, size_t dest_len, const char* src, int src_len);
28 
37 char* uri_unescape(char* dest, size_t dest_len, const char* src, int src_len);
38 
39 unsigned html_escape_len(const char* s, size_t len);
40 void html_escape(char* dest, size_t len, const char* s);
41 
47 char* uri_unescape_inplace(char* str);
48 
55 String uri_escape(const char* src, int src_len);
56 
57 static inline String uri_escape(const String& src)
58 {
59  return src ? uri_escape(src.c_str(), src.length()) : src;
60 }
61 
68 
72 static inline String uri_unescape(const String& str)
73 {
74  String ret = str;
76  return ret;
77 }
const char * c_str() const
Get a constant (un-modifiable) pointer to String content.
Definition: WString.h:641
#define str(s)
Definition: testrunner.h:124
The String class.
Definition: WString.h:136
char * uri_escape(char *dest, size_t dest_len, const char *src, int src_len)
Escape text.
size_t length(void) const
Obtain the String length in characters, excluding NUL terminator.
Definition: WString.h:237
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
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)