15,979
社区成员
发帖
与我相关
我的任务
分享
//
// CString strOrg;
// WCHAR buf[255];
// CStringW strWide = CT2CW(strOrg); // 将T字符转换成宽字符
// wcscpy(buf, strWide);
m_pImage = Image::FromFile(buf);
WCHAR wBuf[255];
// MByteToWChar(buf,wBuf,255);
// for (int i =0;i<255;i++)
// {
// TRACE("%c",wBuf[i]);
// }
m_pImage = Image::FromFile(wBuf);;
得到的结果一样。 char buf[255];
strcpy(buf, str);
WCHAR wBuf[255];
MByteToWChar(buf,wBuf,255);
for (int i =0;i<255;i++)
{
TRACE("%c",wBuf[i]);
}
#include <afxpriv.h>
#include <stdio.h>
char str[3]="汉";
wchar_t ws[2];
int main() {
USES_CONVERSION;
swprintf(ws,L"%s",A2W(str));
printf("%04hX\n",(unsigned short)ws[0]);
return 0;
}
//6C49
//
#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;
INT main()
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
Image* image = new Image(L"FakePhoto.jpg");
printf("The width of the image is %u.\n", image->GetWidth());
printf("The height of the image is %u.\n", image->GetHeight());
delete image;
GdiplusShutdown(gdiplusToken);
return 0;
}
BOOL MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize)
{
DWORD dwMinSize;
dwMinSize = MultiByteToWideChar (CP_ACP, 0, lpcszStr, -1, NULL, 0);
if(dwSize < dwMinSize)
{ return FALSE; }
MultiByteToWideChar (CP_ACP, 0, lpcszStr, -1, lpwszStr, dwMinSize);
return TRUE;
}