| 
 UTF8-ANSI.cpp
 UTF8-ANSI.cpp 
//首先从UTF8转到UNCODE        //再从UNCODE转到ANSI       </SPAN>int ConvUtf8ToAnsi(CString& strSource, CString& strChAnsi)     </SPAN>{    if (strSource.GetLength() <= 0)     </SPAN>        return 0;     </SPAN>    CString strWChUnicode;    strSource.TrimLeft();    strSource.TrimRight();    strChAnsi.Empty();    int iLenByWChNeed = MultiByteToWideChar(CP_UTF8, 0,      </SPAN>                                            strSource.GetBuffer(0),                                            strSource.GetLength(), //MultiByteToWideChar       </SPAN>                                            NULL, 0);    int iLenByWchDone = MultiByteToWideChar(CP_UTF8, 0,      </SPAN>                                            strSource.GetBuffer(0),                                            strSource.GetLength(),                                            (LPWSTR)strWChUnicode.GetBuffer(iLenByWChNeed * 2),      </SPAN>                                            iLenByWChNeed); //MultiByteToWideChar       </SPAN>    strWChUnicode.ReleaseBuffer(iLenByWchDone * 2);    int iLenByChNeed  = WideCharToMultiByte(CP_ACP, 0,      </SPAN>                                            (LPCWSTR)strWChUnicode.GetBuffer(0),     </SPAN>                                            iLenByWchDone,                                            NULL, 0,                                            NULL, NULL);    int iLenByChDone  = WideCharToMultiByte(CP_ACP, 0,      </SPAN>                                            (LPCWSTR)strWChUnicode.GetBuffer(0),      </SPAN>                                            iLenByWchDone,                                            strChAnsi.GetBuffer(iLenByChNeed),                                            iLenByChNeed,                                            NULL, NULL);    strChAnsi.ReleaseBuffer(iLenByChDone);    if (iLenByWChNeed != iLenByWchDone || iLenByChNeed != iLenByChDone)     </SPAN>        return 1;     </SPAN>    return 0;         </SPAN>}    
 |