c语言解析url编码,在C语言中如何实现对编码后的URL进行解码

在C语言中如何实现对编码后的URL进行解码

关注:137  答案:2  信息版本:手机版

解决时间 2019-01-11 02:36

蓝琪梦莎

2019-01-10 13:44

在C语言中如何实现对编码后的URL进行解码

最佳答案

雾月

2019-01-10 14:42

字符串与数字量的转换,可以按照标准的编码(如Unicode,utf8等等)进行编码解码。URL编码就有编码规则,解码时就按既定的编码规则进行就可以了。

全部回答

1楼风格不统一

2019-01-10 16:18

turbo c 2.0编译通过

#include

#include

#include

#define  length  100

void    encode(char    *strsource);

void    decode(char    *strcode);

void  main()

{

char  code[length]="bill  gates";

encode(code);

printf("\nencoded  string  is:%s\n",code);

decode(code);

printf("\ndecoded  string  is:%s\n",code);

getch();

}

void  encode(char  *strsource){

char  *p=strsource,tmp[length]={'\0'},buffer[3];

while(*p){

itoa(*p++,buffer,10);

strcat(tmp,"%");

strcat(tmp,buffer);

}

strcpy(strsource,tmp);

}

void  decode(char  *strcode){

int  i=0;

char  *p,*s=strcode,tmp[length]={'\0'};

char  *csplit="%";

p=strtok(s,csplit);

while(p)

{

tmp[i++]  =  atoi(p);

p=strtok(null,csplit);

}

strcpy(strcode,tmp);

}

我要举报

如以上问答内容为色情/暴力/低俗/不良/侵权等信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!

大家都在看

推荐资讯

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值