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

`utf8ToUcs2` overloads

== Synopses

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

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


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

[.small]#xref:BloombergLP/bdlde/CharConvertUcs2/utf8ToUcs2-06.adoc[_» more&period;&period;&period;_]#

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


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

[.small]#xref:BloombergLP/bdlde/CharConvertUcs2/utf8ToUcs2-04.adoc[_» more&period;&period;&period;_]#

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


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

[.small]#xref:BloombergLP/bdlde/CharConvertUcs2/utf8ToUcs2-09.adoc[_» more&period;&period;&period;_]#

Convert a null&hyphen;terminated UTF&hyphen;8 string to UCS&hyphen;2 in a fixed buffer&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/bdlde/CharConvertUcs2/utf8ToUcs2-0d2.adoc[utf8ToUcs2](
    unsigned short* dstBuffer,
    std::size&lowbar;t dstCapacity,
    char const* srcString,
    std::size&lowbar;t* numCharsWritten = 0,
    unsigned short errorCharacter = &apos;?&apos;);
----

[.small]#xref:BloombergLP/bdlde/CharConvertUcs2/utf8ToUcs2-0d2.adoc[_» more&period;&period;&period;_]#

== Return Value

* 0 on success and `CharConvertStatus&colon;&colon;k&lowbar;INVALID&lowbar;INPUT&lowbar;BIT` otherwise
* 0 on success and a non&hyphen;zero status otherwise
* 0 on success and a bitwise&hyphen;or of the masks specified by `CharConvertStatus&colon;&colon;Enum` 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
| *dstBuffer*
| output buffer for the UCS&hyphen;2 conversion
| *dstCapacity*
| capacity of `dstBuffer` in `unsigned short`s
| *numCharsWritten*
| if non&hyphen;null, receives character count written
|===


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