FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
public static std::string FB::URI::url_encode ( const std::string &  in)
static

Encodes the given URL for transmission.

std::string encoded = FB::URI::url_encode("http://www.firebreath.org/display/documentation/Mac Video Tutorial")
Parameters
inurlencoded URL
Returns
std::string raw URL (not encoded)
Since
1.4b1
See Also
url_decode

Definition at line 37 of file URI.cpp.

37  {
38  std::stringstream res;
39  for (size_t i = 0; i < in.size(); ++i) {
40  char c = in[i];
41  if (c > 0 && (isalnum(c) || c == '+' ||
42  c == '$' || c == '-' || c == '_' || c == '.' || c == '!' ||
43  c == '*' || c == '\''|| c == '(' || c == ')' || c == ',' || c == '/')) res << c;
44  else {
45  char buf[4];
46  sprintf(buf, "%%%.2x", c & 0xff);
47  res << buf;
48  }
49  }
50  return res.str();
51 }