BloombergLP::bdlde::CharConvertUtf16::utf8ToUtf16

that UTF-16 can validly encode (in the range [ 1 .. 0xd7ff ] or [ 0xe000 .. 0x10ffff ]). If errorChar is 0, invalid input code points are ignored (i.e., produce no corresponding output). The behavior is undefined unless srcString is null-terminated when specified as a const char *. Note that one code point can occupy multiple UTF-16 words, and that if srcString is a bslstl::StringRef, it may contain embedded null bytes that will be translated to null words embedded in the output.

Synopsis

Declared in <bdlde_charconvertutf16.h>

static
int
utf8ToUtf16(
    bsl::wstring* dstString,
    std::string_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    wchar_t errorWord = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);