carb::extras::convertWideStringToUtf8

Defined in carb/extras/Utf8Parser.h

inline size_t carb::extras::convertWideStringToUtf8(const wchar_t *str, char *out, size_t outLen) noexcept

Convert a wide encoded string to UTF-8 string.

Note

This is provided for interoperability with older systems that still use wide strings. Please use UTF-8 or UTF-32 for new systems.

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

  • out[out] The output buffer to hold the wide 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.

Returns

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

Returns

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