Convert the UTF-32 srcString into UTF-8 in dstVector.
Declared in <bdlde_charconvertutf32.h>
static
int
utf32ToUtf8(
bsl::vector<char>* dstVector,
unsigned int const* srcString,
std::size_t* numCodePointsWritten = 0,
unsigned char errorByte = '?',
ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
Load into the specified dstVector the result of converting the specified srcString of UTF-32 values to UTF-8, always followed by a null character, and return 0 on success or CharConvertStatus::k_INVALID_INPUT_BIT if invalid UTF-32 values (in the range [0xD800 .. 0xDFFF] or above 0x10FFFF) are seen. Optionally specify srcStringlength as the number of UTF-32 values to be converted. If srcStringLength is specified, convert that many UTF-32 values from srcString (including zero values), otherwise convert values up to but not including a terminating zero value. Optionally specify numCodePointsWritten to receive the number of UTF-8 code points written to dstVector. Optionally specify errorByte as the character to be written to dstVector as the translation of invalid UTF-32 values; if not specified, ? is used, and if given as 0, no character is written at all. Optionally specify byteOrder to determine how UTF-32 values in srcString are interpreted; if not given, host byte order is used. The behavior is undefined if errorByte is 0x80 or above. Note that if you are passing the bsl::vector<unsigned int> obtained from a call to utf8ToUtf32 and using srcStringLength, you must take care to pass vector.size() - 1 to srcStringLength to avoid embedding the terminating 0.
0 on success or CharConvertStatus::k_INVALID_INPUT_BIT on invalid input
| Name | Description |
|---|---|
| dstVector | destination for the null-terminated UTF-8 result |
| srcString | null-terminated UTF-32 source string to convert |
| numCodePointsWritten | if non-null, receives the number of UTF-8 code points written |
| errorByte | optional substitute for invalid UTF-32 values; 0 writes nothing |
| byteOrder | byte order of the UTF-32 input (host by default) |