[#BloombergLP-bdlb-Print-printString]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/Print.adoc[Print]::printString
:relfileprefix: ../../../
:mrdocs:

Print a character string to a stream, escaping non&hyphen;printables&period;

== Synopsis

Declared in `&lt;bdlb&lowbar;print&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
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`&period; If the optionally specified `escapeBackSlash` flag is `true`, then all occurrences of the backslash character (&apos;&apos;) in the `string` are escaped (i&period;e&period;, expanded to &quot;&bsol;&quot;) when written to the `stream`&period; Note that non&hyphen;printable characters in `string` will be printed in their hexadecimal representation (&apos;xHH&apos;)&period; If `stream` is not valid on entry, this operation has no effect&period; The behavior is undefined unless `0 &lt;&equals; length`&period;

== Return Value

a reference to `stream`

== Parameters

[cols="1,4"]
|===
| 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
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
