hartransform.cpp

来自「有关win32应用程序编程和wince应用程序编程的很全面」· C++ 代码 · 共 46 行

CPP
46
字号
// harTransform.cpp: implementation of the CharTransform class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "harTransform.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CharTransform::CharTransform()
{

}

CharTransform::~CharTransform()
{

}

TCHAR* CharTransform::CharToTChar(char *source)
{
	long iLen = 0;

	iLen = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,source, -1, NULL,0);
	TCHAR* res = (TCHAR*)LocalAlloc(LMEM_ZEROINIT,((iLen+1)/4*4+4)*2);
	if(!res)
	{
		int error = GetLastError();
		return NULL;
	}
	int a= MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,source,-1,res,iLen);
	int b = strlen(source);
	return res;
}

char* CharTransform::TCharToChar(TCHAR *source)
{
	int iLen = 0;
	iLen = WideCharToMultiByte(CP_ACP,0,source, -1, NULL,0,NULL,NULL);
	char* res = new char[(iLen+1)/4*4+4];
	WideCharToMultiByte(CP_ACP,0,source, -1, res,iLen,NULL,NULL);
	return res;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?