String128 -> UTF8String conversion

The VST SDK api deal with char16 (through TChar), for example

IEditController::getParamStringByValue (ParamID id, ParamValue valueNormalized /*in*/, String128 string /*out*/)

where String128 is a TChar[128] array.

VSTGUI defines the UTF8String and uses it in throughout (like CTextLabel).

Is there a convenient way in the SDK to convert a String128 (which is an array of char16) to a UTF8String (which is essentially a wrapper around std::string which is an array of char, but that are properly utf8 encoded)? If not, what would you recommend?

Thanks
Yan

I think I found an answer in the code: vstgui/vst3editor.cpp at bb93128afc4509e74d8556891b1f03647a1a9660 · steinbergmedia/vstgui · GitHub

	bool convertValueToString (float value, char utf8String[256])
	{
		if (parameter)
		{
			Steinberg::Vst::String128 utf16Str;
			if (parameter && parameter->getInfo ().stepCount)
			{
				// convert back to normalized value
				value = (float)editController->plainParamToNormalized (getParameterID (), (Steinberg::Vst::ParamValue)value);
			}
			editController->getParamStringByValue (getParameterID (), value, utf16Str);
			Steinberg::String utf8Str (utf16Str);
			utf8Str.toMultiByte (Steinberg::kCP_Utf8);
			utf8Str.copyTo8 (utf8String, 0, 256);
			return true;
		}
		return false;
	}

Is this the correct way?

Thanks for confirming
Yan