Escaping ampersand in URL

I am trying to send a GET message that contains strings with ampersands and can’t figure how to escape the ampersand in the URL.

Example:

http://www.example.com?candy_name=M&M
result => candy_name = M

I also tried:

http://www.example.com?candy_name=M\&M
result => candy_name = M\\

I am using URLs manually, so I just need the correct characters.

I can’t use any libraries. How can it be done?

8 Answers
8

Leave a Comment