Defined in carb/extras/Utf8Parser.h

inline size_t carb::extras::convertUtf8StringToUtf16(const char *str, char16_t *out, size_t outLen) noexcept

Convert a UTF-8 encoded string to UTF-16.

  • str[in] The input UTF-8 string to convert. This may not be nullptr.

  • out[out] The output buffer to hold the UTF-16 data. This must be at least outLen in length, in elements. This can be nullptr to calculate the required output buffer length. The output string written to out will always be null terminated (unless outLen is 0), even if the string had to be truncated.

  • outLen[in] The length of out, in elements. This should be 1 if out is nullptr.


If out is not nullptr, this returns the number of UTF-32 characters written to out. This includes the null terminating character.


If out is nullptr, this returns the required buffer length to store the output string.