[#BloombergLP-bdljsn-StringUtil-writeString]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdljsn.adoc[bdljsn]::xref:BloombergLP/bdljsn/StringUtil.adoc[StringUtil]::writeString
:relfileprefix: ../../../
:mrdocs:

Write a JSON&hyphen;compliant encoding of `string` to `stream`&period;

== Synopsis

Declared in `&lt;bdljsn&lowbar;stringutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
writeString(
    std::ostream& stream,
    std::string&lowbar;view const& string,
    int flags = e&lowbar;NONE);
----

== Description

Write to the specified `stream` a JSON&hyphen;compliant string that is equivalent to the specified `string`, an arbitrary UTF&hyphen;8 codepoint sequence&period; Return 0 on success and a non&hyphen;zero value otherwise&period; The operation fails if `string` is not a sequence of UTF&hyphen;8 codepoints or if there is an error writing to `stream`&period; See &lsqb;&rsqb;Arbitrary UTF&hyphen;8 to JSON String) for further details&period;

== Return Value

0 on success, and a non&hyphen;zero value otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *stream*
| output stream
| *string*
| UTF&hyphen;8 codepoint sequence to encode
| *flags*
| optional encoding flags
|===


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