9 Replies - 283 Views - Last Post: 19 February 2011 - 09:07 AM Rate Topic: -----

#1 m4unot  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 163
  • Joined: 05-June 10

Pointers

Posted 19 February 2011 - 06:38 AM

I have a pointer:

char * text = "King's Test Text";

how can I encode / convert this pointer to appear like this:

King%60s%20Test%20Text
Is This A Good Question/Topic? 0
  • +

Replies To: Pointers

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6052
  • View blog
  • Posts: 23,487
  • Joined: 23-August 08

Re: Pointers

Posted 19 February 2011 - 06:42 AM

http://www.zedwood.c...encode-function
Was This Post Helpful? 0
  • +
  • -

#3 m4unot  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 163
  • Joined: 05-June 10

Re: Pointers

Posted 19 February 2011 - 06:47 AM

View PostJackOfAllTrades, on 19 February 2011 - 06:42 AM, said:

[url]http://www.zedwood.com/article/111/cpp-urlencode-function[/url]



can you give me a eksample, please+
Was This Post Helpful? 0
  • +
  • -

#4 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Pointers

Posted 19 February 2011 - 06:55 AM

Did you goto the page JackOfAllTrades gave you????
Was This Post Helpful? 0
  • +
  • -

#5 m4unot  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 163
  • Joined: 05-June 10

Re: Pointers

Posted 19 February 2011 - 06:56 AM

View Postn8wxs, on 19 February 2011 - 06:55 AM, said:

Did you goto the page JackOfAllTrades gave you????



Yes, but the code is hard to understand.
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6052
  • View blog
  • Posts: 23,487
  • Joined: 23-August 08

Re: Pointers

Posted 19 February 2011 - 06:59 AM

How about you give it a try, huh? The logic is right there on the page.
Was This Post Helpful? 0
  • +
  • -

#7 m4unot  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 163
  • Joined: 05-June 10

Re: Pointers

Posted 19 February 2011 - 07:06 AM

View PostJackOfAllTrades, on 19 February 2011 - 06:59 AM, said:

How about you give it a try, huh? The logic is right there on the page.



I get : King's%20Test%20Text , but not: King%60s%20Test%20Text

This post has been edited by m4unot: 19 February 2011 - 07:08 AM

Was This Post Helpful? 0
  • +
  • -

#8 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Pointers

Posted 19 February 2011 - 07:37 AM

Works for me:

address=King`s Test Text
address=King%60s%20Test%20Text

Hit ENTER to continue...



You are using " ' " not " ` "

edit: I simplified the for() loop a bit:

for (int i = 0; i < max; i++)
{
	if ( 
		isalnum(c[i]) || 
		c[i]=='~'     ||
		c[i]=='!'     ||
		c[i]=='*'     ||
		c[i]=='('     ||
		c[i]==')'     ||
		c[i]=='\''
		)
	{
		escaped.append( &c[i], 1);
	}
	else
	{
		escaped.append("%");
		escaped.append( char2hex(c[i]) );//converts char 255 to string "ff"
	}
}



:)

This post has been edited by n8wxs: 19 February 2011 - 07:45 AM

Was This Post Helpful? 0
  • +
  • -

#9 m4unot  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 163
  • Joined: 05-June 10

Re: Pointers

Posted 19 February 2011 - 07:52 AM

View Postn8wxs, on 19 February 2011 - 07:37 AM, said:

Works for me:

address=King`s Test Text
address=King%60s%20Test%20Text

Hit ENTER to continue...



You are using " ' " not " ` "

edit: I simplified the for() loop a bit:

for (int i = 0; i < max; i++)
{
	if ( 
		isalnum(c[i]) || 
		c[i]=='~'     ||
		c[i]=='!'     ||
		c[i]=='*'     ||
		c[i]=='('     ||
		c[i]==')'     ||
		c[i]=='\''
		)
	{
		escaped.append( &c[i], 1);
	}
	else
	{
		escaped.append("%");
		escaped.append( char2hex(c[i]) );//converts char 255 to string "ff"
	}
}



:)


It looks beautiful out, thanks to you. :sweatdrop:
Was This Post Helpful? 0
  • +
  • -

#10 shintetsu_80  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 105
  • Joined: 01-July 08

Re: Pointers

Posted 19 February 2011 - 09:07 AM

View Postm4unot, on 19 February 2011 - 07:06 AM, said:

View PostJackOfAllTrades, on 19 February 2011 - 06:59 AM, said:

How about you give it a try, huh? The logic is right there on the page.



I get : King's%20Test%20Text , but not: King%60s%20Test%20Text


Do whatever you did to split (tokenize) over the white space and do it again to split (tokenize) over the apostrophe.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1