[#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‐2 conversion of the null‐terminated UTF‐8 `srcString`. == Synopsis Declared in `<bdlde_charconvertucs2.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static int utf8ToUcs2( xref:bsl/vector-00d.adoc[bsl::vector<unsigned short>]* result, char const* srcString, unsigned short errorCharacter = '?'); ---- == Description Load into the specified `result` the conversion of the specified null‐terminated UTF‐8 `srcString` to its null‐terminated UCS‐2 equivalent. Optionally specify `errorCharacter` to be substituted for invalid (i.e., not convertible to UCS‐2) input characters. If `errorCharacter` is 0, invalid input characters are ignored (i.e., produce no corresponding output characters). 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 UCS‐2. If the return value has `CharConvertStatus::k_INVALID_INPUT_BIT` set, one or more input characters are invalid (in which case the conversion continues). The behavior is undefined unless `srcString` is null‐terminated. Note that the null‐terminating word counts towards `result‐>size()`. == Return Value 0 on success and `CharConvertStatus::k_INVALID_INPUT_BIT` otherwise == Parameters [cols="1,4"] |=== | Name| Description | *result* | output vector for the UCS‐2 conversion | *srcString* | null‐terminated UTF‐8 input | *errorCharacter* | substitute for invalid input; 0 skips them |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#