1

'&' is used as separator between key and value pairs.

But one of my value contains '&', how can I send this data?

lucky me
  • 73
  • 1
  • 7

1 Answers1

2

You will have to url encode it (most http related libraries have utility functions for doing so).

For example, key=&value will become key=%26value

You can find more information in Wikipedia.

When a character from the reserved set (a "reserved character") has special meaning (a "reserved purpose") in a certain context, and a URI scheme says that it is necessary to use that character for some other purpose, then the character must be percent-encoded. Percent-encoding a reserved character involves converting the character to its corresponding byte value in ASCII and then representing that value as a pair of hexadecimal digits. The digits, preceded by a percent sign ("%") which is used as an escape character, are then used in the URI in place of the reserved character. (For a non-ASCII character, it is typically converted to its byte sequence in UTF-8, and then each byte value is represented as above.) The reserved character "/", for example, if used in the "path" component of a URI, has the special meaning of being a delimiter between path segments. If, according to a given URI scheme, "/" needs to be in a path segment, then the three characters "%2F" or "%2f" must be used in the segment instead of a raw "/".

This question is probably a duplicate of this.

Community
  • 1
  • 1
Nandana
  • 1,240
  • 8
  • 17
  • Thanks. My code is in C++, and I dont see standard function to do that. Please let me if there is one. – lucky me Jan 31 '15 at 00:50
  • Answers to this question [1] should provide you some links to libraries [2] and code. [1] http://stackoverflow.com/questions/154536/encode-decode-urls-in-c [2] http://curl.haxx.se/libcurl/c/curl_easy_escape.html – Nandana Jan 31 '15 at 11:59
  • Other options can be to checkout the php code itself. You can peek the function php_url_encode and php_url_decode in ext/standard/url.c. – Ritesh Apr 05 '15 at 21:46