char *unicodeToUtf8(const WCHAR *zWideFilename) WCHAR *mbcsToUnicode(const char *zFilename)
char *unicodeToUtf8(const WCHAR *zWideFilename)   
{   
	int nByte;   
	char *zFilename;   
	nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0);   
	zFilename = (char *)malloc(nByte);   
	if(zFilename == 0)   
	{   
		return 0;   
	}   
	nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, zFilename, nByte, 0, 0);   
	if( nByte == 0 )   
	{   
		free(zFilename);   
		zFilename = 0;   
	}   
	return zFilename;   
}   

WCHAR *mbcsToUnicode(const char *zFilename)   
{   
	int nByte;   
	WCHAR *zMbcsFilename;   
	int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;   
	nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, NULL,0)*sizeof(WCHAR);   
	zMbcsFilename = (WCHAR *)malloc(nByte*sizeof(zMbcsFilename[0]));   
	if( zMbcsFilename==0 )   
	{   
		return 0;   
	}   
	nByte = MultiByteToWideChar(codepage, 0, zFilename, -1,    zMbcsFilename, nByte);   
	if(nByte == 0)   
	{   
		free(zMbcsFilename);   
		zMbcsFilename = 0;   
	}   
	return zMbcsFilename;   
}  

阅读更多
文章标签: null
个人分类: c++MFC学习笔记
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

char *unicodeToUtf8(const WCHAR *zWideFilename) WCHAR *mbcsToUnicode(const char *zFilename)

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭