diff options
Diffstat (limited to 'vespalib/src/vespa/vespalib/util/string_escape.h')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/string_escape.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/util/string_escape.h b/vespalib/src/vespa/vespalib/util/string_escape.h new file mode 100644 index 00000000000..3ad926dafc4 --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/string_escape.h @@ -0,0 +1,26 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/stllike/string.h> +#include <iosfwd> + +namespace vespalib { + +/** + * Returns input string but where the following characters are escaped: + * - all control chars < char value 32 + * - <, >, &, " and ' + */ +[[nodiscard]] vespalib::string xml_attribute_escaped(vespalib::stringref s); + +/** + * Returns input string but where the following characters are escaped: + * - all control chars < char value 32, _except_ linebreak + * - <, > and & + */ +[[nodiscard]] vespalib::string xml_content_escaped(vespalib::stringref s); +void write_xml_content_escaped(vespalib::asciistream& out, vespalib::stringref s); +void write_xml_content_escaped(std::ostream& out, vespalib::stringref s); + +} |