Convert A_UTF16Char to Standard String
Trying to get the footage path to be used in a stream for my plugin, however running into some trouble converting a A_UTF16Char into a standard string. Was trying conversions with wstring_convert, but this keeps giving me access violation errors. Does anyone have a good system for this? Thanks!
std::string utf16_to_utf8(std::wstring utf16_string)
{
return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t>{}.to_bytes(utf16_string);
}
[...]
AEGP_ItemH layer_itemH = NULL;
AEGP_MemHandle pathH;
AEGP_ItemType item_type;
AEGP_FootageH layer_footageH = NULL;
ERR(suites.LayerSuite7()->AEGP_GetLayerSourceItem(layerH, &layer_itemH));
ERR(suites.ItemSuite6()->AEGP_GetItemType(layer_itemH, &item_type));
ERR(suites.FootageSuite5()->AEGP_GetMainFootageFromItem(layer_itemH, &layer_footageH));
ERR(suites.FootageSuite5()->AEGP_GetFootagePath(layer_footageH, 0, AEGP_FOOTAGE_MAIN_FILE_INDEX, &pathH));
if (item_type == AEGP_ItemType_FOOTAGE && !err && pathH) {
std::wstring res16;
ERR(suites.MemorySuite1()->AEGP_LockMemHandle(pathH, reinterpret_cast<void**>(&res16)));
if (res16.size() > 0) {
std::string resStr = utf16_to_utf8(res16);
[...]
}
ERR(suites.MemorySuite1()->AEGP_UnlockMemHandle(pathH));
}

