Skip to content

Rose::StringUtility::cEscape

Escapes characters that are special to C/C++.

Synopsis

Declared in <src/Rose/StringUtility/Escape.h>

[[visibility]]
std::string
cEscape(
    std::string const&,
    char context = '"');

Description

Replaces special characters in the input so that it is suitable for the contents of a C string literal (if context is a double quote character) or the contents of a C character constant (if context is a single quote). That is, things like double quotes, line‐feeds, tabs, non‐printables, etc. are replace by their C backslash escaped versions. Returns the resulting string.

Note that if the first argument is a string then the context defaults to string literals, and if the first argument is a single character then the context defaults to character literals. Although this is usually what one wants, it's possible to change the context in both situations.

@{

Return Value

Escaped string.

Parameters

Name

Description

context

Quote character selecting string or character escaping.

Created with MrDocs