[#BloombergLP-bdlde-CharConvertUtf16-utf8ToUtf16-04]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlde.adoc[bdlde]::xref:BloombergLP/bdlde/CharConvertUtf16.adoc[CharConvertUtf16]::utf8ToUtf16
:relfileprefix: ../../../
:mrdocs:

that UTF&hyphen;16 can validly encode (in the range `&lsqb; 1 &period;&period; 0xd7ff &rsqb;` or `&lsqb; 0xe000 &period;&period; 0x10ffff &rsqb;`)&period; If `errorChar` is 0, invalid input code points are ignored (i&period;e&period;, produce no corresponding output)&period; The behavior is undefined unless `srcString` is null&hyphen;terminated when specified as a `const char &ast;`&period; Note that one code point can occupy multiple UTF&hyphen;16 words, and that if `srcString` is a `bslstl&colon;&colon;StringRef`, it may contain embedded null bytes that will be translated to null words embedded in the output&period;

== Synopsis

Declared in `&lt;bdlde&lowbar;charconvertutf16&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
utf8ToUtf16(
    xref:bsl/wstring.adoc[bsl::wstring]* dstString,
    std::string&lowbar;view const& srcString,
    std::size&lowbar;t* numCodePointsWritten = 0,
    wchar&lowbar;t errorWord = &apos;?&apos;,
    xref:BloombergLP/bdlde/ByteOrder/Enum.adoc[ByteOrder::Enum] byteOrder = ByteOrder&colon;&colon;e&lowbar;HOST);
----


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