u32 gf_utf8_mbstowcs(unsigned short* dest, size_t len, const char** srcp)
{
	if (!srcp || !*srcp)
		return 0;
	else {
		const UTF8** sourceStart = (const UTF8**) srcp;
		const UTF8* sourceEnd = (const UTF8*) ( *srcp + strlen( *srcp) );
		UTF16* targetStart = (UTF16* ) dest;
		UTF16* targetEnd = (UTF16* ) (dest + len);
		ConversionFlags flags = strictConversion;
		ConversionResult res = ConvertUTF8toUTF16(sourceStart, sourceEnd, &targetStart, targetEnd, flags);
		if (res != conversionOK) return GF_UTF8_FAIL;
		*targetStart = 0;
		*srcp=NULL;
		return gf_utf8_wcslen(dest);
	}
}
u32 gf_utf8_mbstowcs(unsigned short* dest, size_t len, const char** srcp)
{
	if (!srcp || !*srcp)
		return 0;
	else {
		const UTF8** sourceStart = (const UTF8**) srcp;
		const UTF8* sourceEnd = (const UTF8*) ( *srcp + strlen( *srcp) );
		UTF16* targetStart = (UTF16* ) dest;
		UTF16* targetEnd = (UTF16* ) (dest + len);
		ConversionFlags flags = strictConversion;
		ConversionResult res = ConvertUTF8toUTF16(sourceStart, sourceEnd, &targetStart, targetEnd, flags);
		if (res != conversionOK) return GF_UTF8_FAIL;
		*targetStart = 0;
		*srcp=NULL;
		return gf_utf8_wcslen(dest);
	}
}