替换字符串 [英] replace string

查看:78
本文介绍了替换字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个网址,这是一个字母*


char * url =" / url =%2Fhome%2Fsumit%2Fpackages% 2Fmyxml.xml" ;;


当我将此URL发送到http服务器时,它就像 -


" / url = / home / sumit /pacakges/myxml.xml"


但当它通过http服务器获取时它将''/''转换为''%2F''我必须

重新转换为''/''

i做了很多字符串操作,但我没有得到真正的字符串,

我还在尝试。任何人都可以请你知道如何更换''%2F''

''/''

谢谢



I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"

but when it get by http server it convert ''/'' to ''%2F'' i have to
reconvert it to ''/''
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace ''%2F'' to
''/''
Thanks


推荐答案

Sumit写道:
Sumit wrote:

hi,

我有一个网址这是一个字母*


char * url =" / url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml" ;;


当我将此URL发送到http服务器时,它就像 -


" /url=/home/sumit/pacakges/myxml.xml"


但是当它通过http服务器获得它将''/''转换为''%2F''我必须

将其重新转换为''/''

i做了这么多的字符串操作,但我没有得到真正的字符串,

我还在努力。任何人都可以告诉我如何将''%2F''替换为

''/''

I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"

but when it get by http server it convert ''/'' to ''%2F'' i have to
reconvert it to ''/''
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace ''%2F'' to
''/''



char url [] = " /url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml" ;;

char * p;

while((p = strstr(url,"%2F") ;))!= NULL){

* p =''/'';

memmove(p + 1,p + 3,strlen(p + 2)) ;

}


注意第一行的变化。还要注意,这不是特别高效的b $ b,也不是非常灵活 - 但这就是你要求的b $ b,所以...


-
Er ********* @ sun.com

char url[] = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";
char *p;
while ((p = strstr(url, "%2F")) != NULL) {
*p = ''/'';
memmove (p+1, p+3, strlen(p+2));
}

Note the change in the first line. Also note that this is not
especially efficient, nor tremendously flexible -- but it''s what you
asked for, so ...

--
Er*********@sun.com


2008年11月4日17:02,Eric Sosman写道:
On 4 Nov 2008 at 17:02, Eric Sosman wrote:

char url [] =" /url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml" ;;

char * p;

while((p = strstr( url,"%2F"))!= NULL){

* p =''/'';

memmove(p + 1,p + 3,strlen (p + 2));

}


另请注意,这不是特别有效,也不是非常有效

灵活
char url[] = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";
char *p;
while ((p = strstr(url, "%2F")) != NULL) {
*p = ''/'';
memmove (p+1, p+3, strlen(p+2));
}

Also note that this is not especially efficient, nor tremendously
flexible



谈论本世纪的轻描淡写 - 这就是理查德希思菲尔德效率学校的优势。


您是否可以通过试图引导他们来嘲笑新海报

花园小径故意愚蠢的解决方案Eric?

Talk about the understatement of the century - that''s right out of the
Richard Heath Field school of efficiency.

Do you get a kick out of mocking new posters by trying to lead them down
the garden path with a deliberately silly solution Eric?


Sumit写道,On 04/11/08 16:53:
Sumit wrote, On 04/11/08 16:53:



我有一个网址,这是一个字符*



当我将此URL发送到http服务器时,它就像 -


" / url = / home /sumit/pacakges/myxml.xml"

I have a url which is a char *

char * url = "/url=%2Fhome%2Fsumit%2Fpackages%2Fmyxml.xml";

when i send this URL to http server it was like -

"/url=/home/sumit/pacakges/myxml.xml"



它可能看起来像这样,但如果字符串是使用%2F定义的然后我会希望这是实际传输的内容。

It may look like that, but if the string is defined using "%2F" then I
would expect that to be what is actually transmitted.


但是当它被http服务器获取时它会转换''/''到''%2F''我必须将b $ b重新转换为''/''

i做了如此多的字符串操作,但我没有得到真正的字符串,

我还在努力。任何人都可以告诉我如何更换''%2F''

''/''
but when it get by http server it convert ''/'' to ''%2F'' i have to
reconvert it to ''/''
i did so many string operation but i did not get real string ,
still i am trying. can anyone please give me idea how to replace ''%2F'' to
''/''



告诉我们您的尝试。执行此处理并不困难,只需扫描

字符串为%并将以下两个字符视为十六进制

数字表示所需字符然后复制其余部分

string(虽然仍在寻找%字符)。当然,你还有

来决定如何处理无效输入。

-

Flash Gordon

如果发送垃圾邮件,请将其发送至 sm**@spam.causeway.com

如果通过电子邮件发送给我我的回复地址

请参阅由我主持的comp.lang.c Wiki http://clc-wiki.net/


这篇关于替换字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆