diff --git a/core/string.cpp b/core/string.cpp index 7ede8e2..3813dd0 100644 --- a/core/string.cpp +++ b/core/string.cpp @@ -915,6 +915,22 @@ void String::append_repeat(const String &other, const int times) { } } +void String::to_html_special_chars() { + replace("&", "&"); + replace("\"", """); + replace("'", "'"); + replace("<", "<"); + replace(">", ">"); +} + +void String::from_html_special_chars() { + replace("&", "&"); + replace(""", "\""); + replace("'", "'"); + replace("<", "<"); + replace(">", ">"); +} + bool String::to_bool() const { if (_size == 0) { return 0; diff --git a/core/string.h b/core/string.h index ce87038..213227e 100644 --- a/core/string.h +++ b/core/string.h @@ -97,6 +97,9 @@ public: void append_repeat(const char* str, const int times); void append_repeat(const String &other, const int times); + void to_html_special_chars(); + void from_html_special_chars(); + bool to_bool() const; float to_float() const; double to_double() const;