Print a character string to a stream, escaping non‐printables.

Synopsis

Declared in <bdlb_print.h>

static
std::ostream&
printString(
    std::ostream& stream,
    char const* string,
    int length,
    bool escapeBackSlash = false);

Description

Print to the specified stream the specified string of the specified length and return a reference providing modifiable access to stream. If the optionally specified escapeBackSlash flag is true, then all occurrences of the backslash character ('') in the string are escaped (i.e., expanded to "\") when written to the stream. Note that non‐printable characters in string will be printed in their hexadecimal representation ('xHH'). If stream is not valid on entry, this operation has no effect. The behavior is undefined unless 0 <= length.

Return Value

a reference to stream

Parameters

Name

Description

stream

the output stream

string

the character string to print

length

the length of string in bytes

escapeBackSlash

whether to escape backslash characters

Created with MrDocs