阅读背景:

c#调用c++ dll const char* String类型转换问题。传值,与接收返回值问题

来源:互联网 
C++原型
extern "C" __declspec(dllexport) const  char* GetUnicoide(const char* gb2312)
{
	int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);
	wchar_t* wstr = new wchar_t[len+1];
	memset(wstr, 0, len+1);
	MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len);
	len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
	char* str = new char[len+1];
	memset(str, 0, len+1);
	WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
	if(wstr) delete[] wstr;
	return str;
}extern "C" __declspec(dllexp



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: