赞
踩
- #ifndef _ttol
- #define _ttol ToolBase::TToL
- #endif
-
- class ToolBase
- {
- public:
- static CString UTF8ToGB2312(const char *pSrc, int iLen)
- {
- char pResult[2048] = {0};
- int i = 0, j = 0;
- while (i < iLen)
- {
- if (pSrc[i] < 0 && i+2<iLen && pSrc[i+1] < 0 && pSrc[i+2] < 0)
- {
- WCHAR Wtemp = UTF8ToUnicode__(pSrc + i);
- char Ctemp[4] = {0};
- UnicodeToGB2312__(Ctemp, Wtemp);
- pResult[j] = Ctemp[0];
- pResult[j + 1] = Ctemp[1];
- i += 3;
- j += 2;
- }
- else
- {
- pResult[j++] = pSrc[i++];
- }
- }
-
- return CString(pResult);
- }
-
- static long TToL(const CString& data)
- {
- USES_CONVERSION;
- char* tmp = T2A(data);
-
- return atol(tmp);
- }
-
- private:
- static WCHAR UTF8ToUnicode__(const char pSrc[3])
- {
- WCHAR Wtemp;
- char* uchar = (char *)&Wtemp;
- uchar[1] = ((pSrc[0] & 0x0F) <<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。