Cbeam
Loading...
Searching...
No Matches
cbeam/convert/string.hpp

Escapes specified characters in a given string.

Escapes specified characters in a given string.This function takes an input string and escapes characters that are found in the characters_to_escape string. Each occurrence of any character from characters_to_escape is prefixed with the specified escape_character.

Parameters
inputThe string to be processed.
escape_characterThe character used for escaping.
characters_to_escapeA string containing all characters that should be escaped.
Returns
A new string with the specified characters escaped.
std::string original = "Hello, world!";
std::string escaped = escape_string(original, '\\', ",!");
// escaped would be "Hello\, world\!"