87,991
社区成员
发帖
与我相关
我的任务
分享
#include <math.h>
#include <iostream>
#include <string>
using namespace std;
long hex2dec(char * s){
int L=strlen(s);
char c;
long re=0;
while(c=s++[0]){
if(c >='0' && c <='9'){
c-=48;
}else{
c=c>'Z'? c-32:c;
c-='A'-10;
}
re+= c*pow( 16 ,--L) ;
}
return re;
}
string unescape(char * str){
char* re =(char *)calloc( strlen(str) +1,1);
char *_str;
char * _re=re;
int n;
char code[5]={0};
char c;
while(str){
_str= strchr(str,'%') ;
if(!_str) break;
strset(code,0);
if(_str[0]=='u'){
memcpy(code,_str+1,4);
}else{
memcpy(code,_str+1,2);
}
c=(char)hex2dec(code);
if( n=_str-str ){
memcpy(_re,str, n );
_re+=n;
}
_re[0]=c;
_re++;
str=_str+3;
}
return re;
cout << re << endl;
}
int main(int argc, char* argv[])
{
char* str="%3CRD%3E%0D%0A%3CTask+ID%3D%2214567%22+TYPE%3D%22CMD%22+%2F%3E%0D%0A%3CCJQ+ID%3D%221%22%2F%3E%0D%0A%3CCMD+DATA%3D%226820AAAAAAAAAAAAAA0303810AC016%22+%2F%3E%0D%0A%3C%2FRD%3E%0D%0A%09";
cout<< unescape(str) << endl;
return 0;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<form enctype="application/x-www-form-urlencoded" accept-charset="utf-8" method="post" action="http://gateway.renzhe.com/">
<textarea rows="3" cols="60" name="message"></textarea>
<input type="submit" value="post" />
</form>
</body>
</html>
PHP
<?php
header('Content-Type: text/xml; charset=utf-8');
$t='<?xml version="1.0" encoding="utf-8"?>';
$t.=$_POST['message'];
echo $t;
flush();
?>