ChartDirector 7.1 (C++ Edition)

UTF8toWCHAR


ChartDirector always uses UTF8 strings of type "char *" in its API. In C++, a common data type for international characters is the wide character type "wchar_t". The UTF8toWCHAR can be used to convert a wide string to a UTF8 string. A related utility class WCHARtoUTF8 performs the reverse conversion.

UTF8toWCHAR has a constructor that accepts a UTF8 character pointer "char *", and an implicit type casting operator to cast to "const wchar_t *". Thus it can be used like a function that accepts a UTF8 string as input and returns a wide string as output. Note that the memory required for the output is from the UTF8toWCHAR object, so it must be used before the object is destroyed.

A typical usage is like:

functionRequiringWideString(UTF8toWCHAR(a_utf8_string));

In the above, the UTF8toWCHAR object is destroyed after the function returns, so the converted wide string is valid for the lifetime of the function call.

MethodInheritedDescription
UTF8toWCHAR(Self)Constructs a UTF8toWCHAR object.
const_wchar_t_ptr(Self)Operator for implicit casting to const wchar_t *.