CString EnCodeStr(CString ToCode)
{
  CString RetStr,AddStr;
  int i,max;
  unsigned short asc;
  unsigned char c;
  max = (unsigned int)ToCode.GetLength();
  for(i=0;i<max;i++)
  {
    c = ToCode[i];
    asc = c;//(unsigned int)c;
    if(asc>47 && asc<58)
    {
      RetStr+=c;//Interim[(int)i];
    }
    else if(asc>64 && asc<91)
    {
      RetStr+=c;//Interim[(int)i];
    }
    else if(asc>96 && asc<123)
    {
      RetStr+=c;//Interim[(int)i];
    }
    else if(asc==32)
    {
      RetStr+="+";
    }
    else
    {
      AddStr.Format("%%%2x",asc);
      int iv = (int)AddStr.GetAt(1);
      if((int)AddStr.GetAt(1)==32)
      {
        AddStr.SetAt(1,'0');
      }
      RetStr+=AddStr;
    }
  }
  return RetStr;
}

CString DeCodeStr(CString ToCode)
{
  CString RetStr,AddStr;
  int i,max;
  unsigned short asc;
  unsigned char c;
  max = (unsigned int)ToCode.GetLength();
  for(i=0;i<max;)
  {
    c = ToCode[i];
    asc = c;//(unsigned int)c;
    if(asc==37)
    {
      AddStr=ToCode.Mid(i+1,2);
      i+=3;
      sscanf((LPCTSTR)AddStr,"%2x",&asc);
      RetStr+=(char)asc;
    }
    else if(asc==43)
    {
      RetStr += ' ';
      i++;
    }
    else
    {
      RetStr += c;
      i++;
    }
  }
  return RetStr;
}
 
2006/10/02 23:26 2006/10/02 23:26

글 걸기 주소 : 이 글에는 트랙백을 보낼 수 없습니다

덧글을 달아 주세요