- WinCE Security...
- xdebug配置说明
- VC++ 获取文件的创建、修...
- ASP进度条
- 简单代理服务器C代码实现(S...
- 程序设计竞赛试题选(02)
- 如何在ASP程序中打印Acc...
- UTF-8和16进制区间
- ASP实用技巧:强制刷新和判...
- 运行中程序删除自己的方法
- asp提高首页性能的一个技巧
- [J2EE]J2EE 应用服务器技术
- VB变量命名规范
- C语言常见错误小结
- (摘自网络)如何在IIS中调...
C++ URL 编码/解码
//URL 编码
std::string urlencode(std::string encode)
{
std::string result;
for(unsigned int i = 0; i< static_cast<unsigned int>(encode.length()); i++)
{
char ch = encode[i];
if(ch == ' ')
{
result += '+';
}else if(ch >= 'A' && ch <= 'Z'){
result += ch;
}else if(ch >= 'a' && ch <= 'z'){
result += ch;
}else if(ch >= '0' && ch <= '9'){
result += ch;
}else if(ch == '-' || ch == '-' || ch == '.' || ch == '!' || ch == '~' || ch == '*' || ch == '\'' || ch == '(' || ch == ')' ){
result += ch;
}else{
result += '%';
result += iChoo::iconv::char_to_hex(ch);
}
}
return result;
}
//URL 解码
std::string urldecode(std::string decode)
{
std::string result;
for(unsigned int i = 0; i< static_cast<unsigned int>(decode.length()); i++)
{
switch(decode[i])
{
case '+':
result += ' ';
break;
case '%':
if(isxdigit(decode[i + 1]) && isxdigit(decode[i + 2]))
{
result += iChoo::iconv::hex_to_char(decode[i+1], decode[i+2]);
i += 2;
}else {
result += '%';
}
break;
default:
result += decode[i];
break;
}
}
return result;
}