首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

VC有没有JS里面encodeURIComponent函数解决办法

2012-04-11 
VC有没有JS里面encodeURIComponent函数还有其它一下 URL 编码的函数 ,在MSDN里我没找到[解决办法]不晓得

VC有没有JS里面encodeURIComponent函数
还有其它一下 URL 编码的函数 ,在MSDN里我没找到

[解决办法]
不晓得 帮顶了。。
[解决办法]
http://hi.baidu.com/jetqu2003/blog/item/c15026a2c8937fabcaefd032.html
[解决办法]

C/C++ code
class CURLCode {public: CURLCode(){}; virtual ~CURLCode(){}; string Encode(const char* lpszData); string Decode(string inTmp);private: inline BYTE toHex(const BYTE &x){ return x > 9 ? x + 55: x + 48; } inline BYTE fromHex(const BYTE &x){ return x > 64 ? x - 55 : x - 48; }}; string CURLCode::Encode(const char* lpszData){ string strResult = "";  unsigned char* pInTmp = (unsigned char*)lpszData; // do encoding while (*pInTmp) {  if(isalnum(*pInTmp))   strResult += *pInTmp;  else   if(isspace(*pInTmp))    strResult += '+';   else   {    strResult += '%';    strResult += toHex(*pInTmp>>4);    strResult += toHex(*pInTmp%16);   }   pInTmp++; } return strResult;}string CURLCode::Decode(string inTmp){ string strResult = ""; int inlen = inTmp.length(); for(int i=0;i<inlen;i++) {  if(inTmp.at(i)=='%')  {   i++;   char c = fromHex(inTmp.at(i++));   c = c << 4;   c += fromHex(inTmp.at(i));   strResult += c;  }  else if(inTmp.at(i)=='+')    strResult += ' ';  else   strResult += inTmp.at(i); } return strResult;}
[解决办法]
简单就用 UrlEscape
精细控制就用 InternetCanonicalizeUrl
[解决办法]
探讨
我用JS的encodeURIComponent把“汽车”转换成了“%E6%B1%BD%E8%BD%A6”用 InternetCanonicalizeUrl 没做到。。

热点排行