乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      收集的轉(zhuǎn)碼內(nèi)容(轉(zhuǎn)載)

       一世的追逐 2012-05-15
      轉(zhuǎn)碼。
      #pragma once
      #include "stdafx.h"
      #include "string"
      using namespace std;
      class CChineseCode
      {
      public:
      static void UTF_8ToUnicode(wchar_t* pOut,char *pText); // 把UTF-8轉(zhuǎn)換成Unicode
      static void UnicodeToUTF_8(char* pOut,wchar_t* pText); //Unicode 轉(zhuǎn)換成UTF-8
      static void UnicodeToGB2312(char* pOut,wchar_t uData); // 把Unicode 轉(zhuǎn)換成 GB2312
      static void Gb2312ToUnicode(wchar_t* pOut,char *gbBuffer);// GB2312 轉(zhuǎn)換成 Unicode
      static void GB2312ToUTF_8(string& pOut,char *pText, int pLen);//GB2312 轉(zhuǎn)為 UTF-8
      static void UTF_8ToGB2312(char* pOut, char *pText, int pLen);//UTF-8 轉(zhuǎn)為 GB2312
      };

      #include ".\chinesecode.h"

      void CChineseCode::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);
      return;
      }

      void CChineseCode::UnicodeToUTF_8(char* pOut,wchar_t* pText)
      {
      // 注意 WCHAR高低字的順序,低字節(jié)在前,高字節(jié)在后
      char* pchar = (char *)pText;

      pOut[0] = (0xE0 | ((pchar[1] & 0xF0) >> 4));
      pOut[1] = (0x80 | ((pchar[1] & 0x0F) << 2)) + ((pchar[0] & 0xC0) >> 6);
      pOut[2] = (0x80 | (pchar[0] & 0x3F));

      return;
      }

      void CChineseCode::UnicodeToGB2312(char* pOut,wchar_t uData)
      {
      WideCharToMultiByte(CP_ACP,NULL,&uData,1,pOut,sizeof(wchar_t),NULL,NULL);
      return;
      }

      void CChineseCode::Gb2312ToUnicode(wchar_t* pOut,char *gbBuffer)
      {
      ::MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,gbBuffer,2,pOut,1);
      return ;
      }

      void CChineseCode::GB2312ToUTF_8(string& pOut,char *pText, int pLen)
      {
      char buf[4];
      int nLength = pLen* 3;
      char* rst = new char[nLength];

      memset(buf,0,4);
      memset(rst,0,nLength);

      int i = 0;
      int j = 0;
      while(i < pLen)
      {
      //如果是英文直接復(fù)制就可以
      if( *(pText + i) >= 0)
      {
      rst[j++] = pText[i++];
      }
      else
      {
      wchar_t pbuffer;
      Gb2312ToUnicode(&pbuffer,pText+i);

      UnicodeToUTF_8(buf,&pbuffer);

      unsigned short int tmp = 0;
      tmp = rst[j] = buf[0];
      tmp = rst[j+1] = buf[1];
      tmp = rst[j+2] = buf[2];

      j += 3;
      i += 2;
      }
      }
      rst[j] = '\0';

      //返回結(jié)果
      pOut = rst;
      delete []rst;

      return;
      }

      void CChineseCode::UTF_8ToGB2312(char* newBuf, char *pText, int pLen)
      {
      char Ctemp[4];
      memset(Ctemp,0,4);

      int i =0;
      int j = 0;

      while(i < pLen)
      {
      if(pText[i] > 0)
      {
      newBuf[j++] = pText[i++];
      }
      else
      {
      WCHAR Wtemp;
      UTF_8ToUnicode(&Wtemp,pText + i);

      UnicodeToGB2312(Ctemp,Wtemp);

      newBuf[j] = Ctemp[0];
      newBuf[j + 1] = Ctemp[1];

      i += 3;
      j += 2;
      }
      }
      newBuf[j] = '\0';
      return;
      }

      inline BYTE toHex(const BYTE &x)
      {
      return x > 9 ? x + 55: x + 48;
      }
      inline BYTE toByte(const BYTE &x)
      {
      return x > 57? x - 55: x - 48;
      }
      CString URLDecode(CString sIn)
      {
      CString sOut;
      const int nLen = sIn.GetLength() + 1;
      register LPBYTE pOutTmp = NULL;
      LPBYTE pOutBuf = NULL;
      register LPBYTE pInTmp = NULL;
      LPBYTE pInBuf =(LPBYTE)sIn.GetBuffer(nLen);
      //alloc out buffer
      pOutBuf = (LPBYTE)sOut.GetBuffer(nLen);

      if(pOutBuf)
      {
      pInTmp = pInBuf;
      pOutTmp = pOutBuf;
      // do encoding
      while (*pInTmp)
      {
      if('%'==*pInTmp)
      {
      pInTmp++;
      *pOutTmp++ = (toByte(*pInTmp)%16<<4) + toByte(*(pInTmp+1))%16;//高4位+低4位
      pInTmp++;
      }
      else if('+'==*pInTmp)
      *pOutTmp++ = ' ';
      else
      *pOutTmp++ = *pInTmp;
      pInTmp++;
      }
      *pOutTmp = '\0';
      sOut.ReleaseBuffer();
      }
      sIn.ReleaseBuffer();

      return sOut;
      }
      CString URLEncode(CString sIn)
      {
      CString sOut;
      const int nLen = sIn.GetLength() + 1;
      register LPBYTE pOutTmp = NULL;
      LPBYTE pOutBuf = NULL;
      register LPBYTE pInTmp = NULL;
      LPBYTE pInBuf =(LPBYTE)sIn.GetBuffer(nLen);
      //alloc out buffer
      pOutBuf = (LPBYTE)sOut.GetBuffer(nLen*3);

      if(pOutBuf)
      {
      pInTmp = pInBuf;
      pOutTmp = pOutBuf;
      // do encoding
      while (*pInTmp)
      {
      if(isalnum(*pInTmp) || '-'==*pInTmp || '_'==*pInTmp || '.'==*pInTmp)
      *pOutTmp++ = *pInTmp;
      else if(isspace(*pInTmp))
      *pOutTmp++ = '+';
      else
      {
      *pOutTmp++ = '%';
      *pOutTmp++ = toHex(*pInTmp>>4);//高4位
      *pOutTmp++ = toHex(*pInTmp%16);//低4位
      }
      pInTmp++;
      }
      *pOutTmp = '\0';
      sOut.ReleaseBuffer();
      }
      sIn.ReleaseBuffer();

      return sOut;
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多