[#BloombergLP-bdlde-CharConvertUcs2-ucs2ToUtf8-01] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlde.adoc[bdlde]::xref:BloombergLP/bdlde/CharConvertUcs2.adoc[CharConvertUcs2]::ucs2ToUtf8 :relfileprefix: ../../../ :mrdocs: Load into `result` the UTF‐8 conversion of the null‐terminated UCS‐2 `srcString`. == Synopsis Declared in `<bdlde_charconvertucs2.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static int ucs2ToUtf8( xref:bsl/string.adoc[bsl::string]* result, unsigned short const* srcString, std::size_t* numCharsWritten = 0); ---- == Description Load, into the specified `result`, the conversion of the specified null‐terminated UCS‐2 `srcString` to its UTF‐8 equivalent. Optionally specify `numCharsWritten` which (if not 0) indicates the modifiable integer into which the number of _characters_ written (including the null terminator) is to be loaded. Return 0 on success and `CharConvertStatus::k_INVALID_INPUT_BIT` otherwise, meaning that at least one sequence of characters was encountered that could not be translated to UTF‐8. The behavior is undefined unless `srcString` is null‐terminated. Note that the null‐terminating character is not counted in `result‐>length()`. Also note that this function does not currently implement failure modes; however, this could change if UTF‐8 input validation is added. == Return Value 0 on success and `CharConvertStatus::k_INVALID_INPUT_BIT` otherwise == Parameters [cols="1,4"] |=== | Name| Description | *result* | output string for the UTF‐8 conversion | *srcString* | null‐terminated UCS‐2 input | *numCharsWritten* | if non‐null, receives character count written |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#