[#BloombergLP-bdlde-CharConvertUcs2-ucs2ToUtf8-00]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlde.adoc[bdlde]::xref:BloombergLP/bdlde/CharConvertUcs2.adoc[CharConvertUcs2]::ucs2ToUtf8
:relfileprefix: ../../../
:mrdocs:

`ucs2ToUtf8` overloads

== Synopses

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

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


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/bdlde/CharConvertUcs2/ucs2ToUtf8-01.adoc[ucs2ToUtf8](
    xref:bsl/string.adoc[bsl::string]* result,
    unsigned short const* srcString,
    std::size&lowbar;t* numCharsWritten = 0);
----

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

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


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/bdlde/CharConvertUcs2/ucs2ToUtf8-0b.adoc[ucs2ToUtf8](
    std::pmr::string* result,
    unsigned short const* srcString,
    std::size&lowbar;t* numCharsWritten = 0);
----

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

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


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/bdlde/CharConvertUcs2/ucs2ToUtf8-06.adoc[ucs2ToUtf8](
    std::string* result,
    unsigned short const* srcString,
    std::size&lowbar;t* numCharsWritten = 0);
----

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

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


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

[.small]#xref:BloombergLP/bdlde/CharConvertUcs2/ucs2ToUtf8-03.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 string for the UTF&hyphen;8 conversion
| *srcString*
| null&hyphen;terminated UCS&hyphen;2 input
| *numCharsWritten*
| if non&hyphen;null, receives character count written
| *dstBuffer*
| output buffer for the UTF&hyphen;8 conversion
| *dstCapacity*
| capacity of `dstBuffer` in bytes
| *numBytesWritten*
| if non&hyphen;null, receives byte count written
|===


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