[#BloombergLP-bdlde-CharConvertUcs2-utf8ToUcs2-06]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlde.adoc[bdlde]::xref:BloombergLP/bdlde/CharConvertUcs2.adoc[CharConvertUcs2]::utf8ToUcs2
:relfileprefix: ../../../
:mrdocs:

Load into `result` the UCS&hyphen;2 conversion of the null&hyphen;terminated UTF&hyphen;8 `srcString`&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
utf8ToUcs2(
    xref:bsl/vector-00d.adoc[bsl::vector&lt;unsigned short&gt;]* result,
    char const* srcString,
    unsigned short errorCharacter = &apos;?&apos;);
----

== Description

Load into the specified `result` the conversion of the specified null&hyphen;terminated UTF&hyphen;8 `srcString` to its null&hyphen;terminated UCS&hyphen;2 equivalent&period; Optionally specify `errorCharacter` to be substituted for invalid (i&period;e&period;, not convertible to UCS&hyphen;2) input characters&period; If `errorCharacter` is 0, invalid input characters are ignored (i&period;e&period;, produce no corresponding output characters)&period; Return 0 on success and `CharConvertStatus&colon;&colon;k&lowbar;INVALID&lowbar;INPUT&lowbar;BIT` otherwise, meaning that at least one sequence of characters was encountered that could not be translated to UCS&hyphen;2&period; If the return value has `CharConvertStatus&colon;&colon;k&lowbar;INVALID&lowbar;INPUT&lowbar;BIT` set, one or more input characters are invalid (in which case the conversion continues)&period; The behavior is undefined unless `srcString` is null&hyphen;terminated&period; Note that the null&hyphen;terminating word counts towards `result&hyphen;&gt;size()`&period;

== Return Value

0 on success and `CharConvertStatus&colon;&colon;k&lowbar;INVALID&lowbar;INPUT&lowbar;BIT` otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *result*
| output vector for the UCS&hyphen;2 conversion
| *srcString*
| null&hyphen;terminated UTF&hyphen;8 input
| *errorCharacter*
| substitute for invalid input&semi; 0 skips them
|===


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