UTF8ToBytes
// TODO: 在此处为应用程序的行为编写代码。
byte src[] = {(byte)228,(byte)184,(byte)173,(byte)229,(byte)155,(byte)189,0}; //中国
int ucCharLen = MultiByteToWideChar(CP_UTF8,0,(LPCSTR)src,-1,NULL,0);
LPWSTR wbuf = new WCHAR[ucCharLen];
memset(wbuf,0,sizeof(wbuf));
MultiByteToWideChar(CP_UTF8,0,(LPCSTR)src,-1,wbuf,ucCharLen);
byte* buf = NULL;
int byteLength = WideCharToMultiByte(CP_UTF8,0,(LPCWSTR)wbuf,-1,NULL,0,NULL,NULL);
buf = new byte[byteLength];
memset(buf,0,sizeof(buf));
WideCharToMultiByte(CP_UTF8,0,(LPCWSTR)wbuf,-1,(LPSTR)buf,byteLength,NULL,NULL);
delete buf;
delete wbuf;
QQ:273352165
evlon#126.com
转载请注明出处。