Convert the UTF-32 srcString into UTF-8 in dstString.
Declared in <bdlde_charconvertutf32.h>
static
int
utf32ToUtf8(
bsl::string* dstString,
unsigned int const* srcString,
std::size_t* numCodePointsWritten = 0,
unsigned char errorByte = '?',
ByteOrder::Enum byteOrder = ByteOrder::e_HOST);
Load into the specified dstString the result of converting the specified srcString of UTF-32 values to UTF-8 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 encountered. 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 dstString, including the null-terminator. Optionally specify errorByte as the character to be written to dstString 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 |
|---|---|
| dstString | destination for the UTF-8 conversion result |
| srcString | null-terminated UTF-32 source string to convert |
| numCodePointsWritten | if non-null, receives the number of UTF-8 code points written (including terminator) |
| errorByte | optional substitute for invalid UTF-32 values; 0 writes nothing |
| byteOrder | byte order of the UTF-32 input (host by default) |