Exemplo n.º 1
0
	DynamicStringA StringToANSIString(const TempString &str)
	{
		UNICODE_STRING srcString;
		str.FillNTString(&srcString);
		DynamicStringA ret;
		size_t newLen = RtlUnicodeStringToAnsiSize(&srcString);
		if (!NT_SUCCESS(RtlUnicodeStringToAnsiString(ret.ToNTString(newLen), &srcString, FALSE)))
			ret.SetLength(0);
		else
			ret.UpdateLengthFromNTString();
		return ret;
	}
Exemplo n.º 2
0
BazisLib::DynamicStringA BazisLib::KEXT::UTF16ToUTF8( const wchar16_t *pString, size_t length /*= -1*/ )
{
	if (length == -1)
	{
		for (length = 0; pString[length]; length++);
	}

	DynamicStringA result;

	size_t size = utf8_encodelen(pString, length * 2, '/', 0);
	if (!size || size == -1)
		return result;

	size_t done = 0;
	char *pCharBuf = result.PreAllocate(size, false);
	utf8_encodestr(pString, length * 2, (uint8_t *)pCharBuf, &done, size + 1, '/', 0);
	result.SetLength(done);
	return result;
}