BloombergLP::bdlde::CharConvertUtf16::utf16ToUtf8

utf16ToUtf8 overloads

Synopses

Declared in <bdlde_charconvertutf16.h>

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    bsl::string* dstString,
    std::u16string_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    bsl::string* dstString,
    std::wstring_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    bsl::string* dstString,
    char16_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the specified dstString the result of converting the specified UTF-16 srcString to its UTF-8 equivalent. Optionally specify numCodePointsWritten, which (if not 0) indicates the location of the modifiable variable into which the number of Unicode code points written, including the null terminator, is to be loaded, where one code point may occupy multiple bytes. Optionally specify an errorByte to be substituted (if not 0) for invalid encodings in the input string. Invalid encodings are incomplete multi-word encodings or parts of a two-word encoding out of their proper sequence. If errorByte is 0, invalid input sequences are ignored (i.e., produce no corresponding output). Any previous contents of the destination are discarded. Optionally specify byteOrder to indicate the byte order of the UTF-16 input; if byteOrder is not specified, the input is assumed to be in host byte order. Return 0 on success and CharConvertStatus::k_INVALID_INPUT_BIT if one or more invalid sequences were encountered in the input. The behavior is undefined unless errorByte is either 0 or a valid single-byte Unicode code point (0 < errorByte < 0x80) and srcString is null-terminated if supplied as a const wchar_t *. Note that if srcString is a bslstl::StringRefWide, it may contain embedded 0 words that will be translated to null bytes embedded in the output.

static
int
utf16ToUtf8(
    bsl::string* dstString,
    unsigned short const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    bsl::string* dstString,
    wchar_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::string* dstString,
    std::u16string_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::string* dstString,
    std::wstring_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::string* dstString,
    char16_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::string* dstString,
    unsigned short const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::string* dstString,
    wchar_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::string* dstString,
    std::u16string_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::string* dstString,
    std::wstring_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::string* dstString,
    char16_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::string* dstString,
    unsigned short const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::string* dstString,
    wchar_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the specified dstVector the null-terminated result of converting the specified UTF-16 srcString to its UTF-8 equivalent. Optionally specify numCodePointsWritten, which (if not 0) indicates the location of the modifiable variable into which the number of Unicode code points written, including the null terminator, is to be loaded, where one code point may occupy multiple bytes. Optionally specify an errorByte to be substituted (if not 0) for invalid encodings in the input string. Invalid encodings are incomplete multi-word encodings or parts of a two-word encoding out of their proper sequence. If errorByte is 0, invalid input sequences are ignored (i.e., produce no corresponding output). Optionally specify byteOrder to indicate the byte order of the UTF-16 input; if byteOrder is not specified, the input is assumed to be in host byte order. Any previous contents of the destination are discarded. Return 0 on success and CharConvertStatus::k_INVALID_INPUT_BIT if one or more invalid sequences were encountered in the input. The behavior is undefined unless errorByte is either 0 or a valid single-byte Unicode code point (0 < errorByte < 0x80) and srcString is null-terminated if supplied as a const wchar_t *. Note that if srcString is a bslstl::StringRef, it may contain embedded 0 words that will be translated to null bytes embedded in the output.

static
int
utf16ToUtf8(
    bsl::vector<char>* dstVector,
    std::u16string_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    bsl::vector<char>* dstVector,
    std::wstring_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    bsl::vector<char>* dstVector,
    char16_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the specified dstVector the null-terminated result of converting the specified UTF-16 *srcString to its UTF-8 equivalent. Optionally specify srcLengthInWords, the number of unsigned shorts of input. If srcLengthInWords is not specified, the input must be terminated by a null word. Optionally specify numCodePointsWritten, which (if not 0) indicates the location of the modifiable variable into which the number of Unicode code points written, including the null terminator, is to be loaded, where one code point may occupy multiple bytes. Optionally specify an errorByte to be substituted (if not 0) for invalid encodings in the input string. Invalid encodings are incomplete multi-word encodings or parts of a two-word encoding out of their proper sequence. If errorByte is 0, invalid input sequences are ignored (i.e., produce no corresponding output). Optionally specify byteOrder to indicate the byte order of the UTF-16 input; if byteOrder is not specified, the input is assumed to be in host byte order. Any previous contents of the destination are discarded. Return 0 on success and CharConvertStatus::k_INVALID_INPUT_BIT if one or more invalid sequences were encountered in the input. The behavior is undefined unless either srcLengthInWords is passed or srcString is null-terminated, and errorByte is either 0 or a valid single-byte Unicode code point (0 < errorByte < 0x80).

static
int
utf16ToUtf8(
    bsl::vector<char>* dstVector,
    unsigned short const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    bsl::vector<char>* dstVector,
    wchar_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::vector<char>* dstVector,
    std::u16string_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::vector<char>* dstVector,
    std::wstring_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::vector<char>* dstVector,
    char16_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::vector<char>* dstVector,
    unsigned short const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::vector<char>* dstVector,
    wchar_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::vector<char>* dstVector,
    std::u16string_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::vector<char>* dstVector,
    std::wstring_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::vector<char>* dstVector,
    char16_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::vector<char>* dstVector,
    unsigned short const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::vector<char>* dstVector,
    wchar_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    bsl::string* dstString,
    unsigned short const* srcString,
    std::size_t srcLengthInWords,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::string* dstString,
    unsigned short const* srcString,
    std::size_t srcLengthInWords,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::string* dstString,
    unsigned short const* srcString,
    std::size_t srcLengthInWords,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    bsl::vector<char>* dstVector,
    unsigned short const* srcString,
    std::size_t srcLengthInWords,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::pmr::vector<char>* dstVector,
    unsigned short const* srcString,
    std::size_t srcLengthInWords,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    std::vector<char>* dstVector,
    unsigned short const* srcString,
    std::size_t srcLengthInWords,
    std::size_t* numCodePointsWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    char* dstBuffer,
    std::size_t dstCapacity,
    std::u16string_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    std::size_t* numBytesWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    char* dstBuffer,
    std::size_t dstCapacity,
    std::wstring_view const& srcString,
    std::size_t* numCodePointsWritten = 0,
    std::size_t* numBytesWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    char* dstBuffer,
    std::size_t dstCapacity,
    char16_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    std::size_t* numBytesWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load, into the specified dstBuffer of the specified dstCapacity, the result of converting the specified UTF-16 srcString to its UTF-8 equivalent. Optionally specify numCodePointsWritten, which (if not 0) indicates the location of the modifiable variable into which the number of Unicode code points (including the terminating 0, if any) written is to be loaded, where one code point can occupy multiple bytes. Optionally specify numBytesWritten, which (if not 0) indicates the location of the modifiable variable into which the number of bytes written (including the null terminator, if any) is to be loaded. Optionally specify an errorByte to be substituted (if not 0) for invalid encodings in the input string. Invalid encodings are incomplete multi-word encodings or parts of a two-word encoding out of their proper sequence. If errorByte is 0, invalid input sequences are ignored (i.e., produce no corresponding output). Optionally specify byteOrder to indicate the byte order of the UTF-16 input; if byteOrder is not specified, the input is assumed to be in host byte order. Return 0 on success and a bitwise-or of the flags defined by CharConvertStatus::Enum otherwise. CharConvertStatus::k_INVALID_INPUT_BIT will be set if one or more invalid sequences were encountered in the input, and CharConvertStatus::k_OUT_OF_SPACE_BIT will be set if the output space was exhausted before conversion was complete. The behavior is undefined unless dstBuffer refers to an array of at least dstCapacity elements, errorByte is either 0 or a valid single-byte Unicode code point (0 < errorByte < 0x80), and srcString is null-terminated if supplied as a pointer. Note that if dstCapacity is 0, this function returns CharConvertStatus::k_OUT_OF_SPACE_BIT set and 0 is written into *numCodePointsWritten and *numBytesWritten (if those pointers are non-null), since there is insufficient space for even a null terminator alone. Also note that since UTF-8 is a variable-length encoding, numBytesWritten may be up to four times numCodePointsWritten, and therefore that an input srcString of dstCapacity code points (including the terminating 0, if present) may not fit into dstBuffer. A one-word (two-byte) UTF-16 code point will require one to three UTF-8 octets (bytes); a two-word (four-byte) UTF-16 code point will always require four UTF-8 octets. Also note that the amount of room needed will vary with the contents of the data and the language being translated, but never will the number of bytes output exceed three times the number of words input. Also note that, if dstCapacity > 0, then, after completion, strlen(dstBuffer) + 1 == *numBytesWritten. Also note that if srcString is a bslstl::StringRef, it may contain embedded 0 words that will be translated to null bytes embedded in the output.

static
int
utf16ToUtf8(
    char* dstBuffer,
    std::size_t dstCapacity,
    unsigned short const* srcString,
    std::size_t* numCodePointsWritten = 0,
    std::size_t* numBytesWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    char* dstBuffer,
    std::size_t dstCapacity,
    wchar_t const* srcString,
    std::size_t* numCodePointsWritten = 0,
    std::size_t* numBytesWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...

Load into the destination the UTF-8 conversion of the UTF-16 source. Return 0 on success and a non-zero status otherwise. See the first utf16ToUtf8 overload in this group for full contract details.

static
int
utf16ToUtf8(
    char* dstBuffer,
    std::size_t dstCapacity,
    unsigned short const* srcString,
    std::size_t srcLengthInWords,
    std::size_t* numCodePointsWritten = 0,
    std::size_t* numBytesWritten = 0,
    char errorByte = '?',
    ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
» more...