BloombergLP::bdlde::CharConvertUcs2::utf8ToUcs2

utf8ToUcs2 overloads

Synopses

Declared in <bdlde_charconvertucs2.h>

Load into result the UCS-2 conversion of the null-terminated UTF-8 srcString.

static
int
utf8ToUcs2(
    bsl::vector<unsigned short>* result,
    char const* srcString,
    unsigned short errorCharacter = '?');
» more...

Load into result the UCS-2 conversion of the null-terminated UTF-8 srcString.

static
int
utf8ToUcs2(
    std::pmr::vector<unsigned short>* result,
    char const* srcString,
    unsigned short errorCharacter = '?');
» more...

Load into result the UCS-2 conversion of the null-terminated UTF-8 srcString.

static
int
utf8ToUcs2(
    std::vector<unsigned short>* result,
    char const* srcString,
    unsigned short errorCharacter = '?');
» more...

Convert a null-terminated UTF-8 string to UCS-2 in a fixed buffer.

static
int
utf8ToUcs2(
    unsigned short* dstBuffer,
    std::size_t dstCapacity,
    char const* srcString,
    std::size_t* numCharsWritten = 0,
    unsigned short errorCharacter = '?');
» more...

Return Value

  • 0 on success and CharConvertStatus::k_INVALID_INPUT_BIT otherwise
  • 0 on success and a non-zero status otherwise
  • 0 on success and a bitwise-or of the masks specified by CharConvertStatus::Enum otherwise

Parameters

NameDescription
resultoutput vector for the UCS-2 conversion
srcStringnull-terminated UTF-8 input
errorCharactersubstitute for invalid input; 0 skips them
dstBufferoutput buffer for the UCS-2 conversion
dstCapacitycapacity of dstBuffer in unsigned shorts
numCharsWrittenif non-null, receives character count written