c++ urlencode简单实现

string urlencode(const string& str)
{
      char* cmem = new char[str.size()*3 + 1]
      memset(cmem,0,str.size()*3+1);
      for(size_t i=0; i<str.size(); ++i)
      {
              sprintf(cmem+i*3,"%%%02X",(unsighed char)str[i]);
      }
      string sencoded(cmem);
      delete[] cmem;
      cmem = NULL;
      return sencoded;
}


你可能感兴趣的:(C++,urlencode)