赞
踩
void UTF_8ToUnicode(wchar_t* pOut,char *pText) { char* uchar = (char *)pOut; uchar[1] = ((pText[0] & 0x0F) << 4) + ((pText[1] >> 2) & 0x0F); uchar[0] = ((pText[1] & 0x03) << 6) + (pText[2] & 0x3F); } void Gb2312ToUnicode(wchar_t* pOut,char *gbBuffer) { ::MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,gbBuffer,2,pOut,1); } void UTF_8ToGB2312(char*pOut, char *pText, int pLen) { char Ctemp[4]; memset(Ctemp,0,4); int i =0 ,j = 0; while(i < pLen) { if(pText[i] >= 0) { pOut[j++] = pText[i++]; } else { WCHAR Wtemp; UTF_8ToUnicode(&Wtemp,pText + i); UnicodeToGB2312(Ctemp,Wtemp); pOut[j] = Ctemp[0]; pOut[j + 1] = Ctemp[1]; i += 3; j += 2; } } pOut[j] ='\n'; return; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。