encodeURIComponent

Oct 3, 2013 at 1:59 PM
Hi!
I'm trying to encode a base64 encoded value as a query string value. Has this library any support for this now? I tried uri::encode_data_string but it won't encode = to %3D.

Documentation from mozilla:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
Coordinator
Oct 3, 2013 at 10:59 PM
I am able to URL encode a base64 encoded string, using the current version (1.2) of this SDK (VS2012 setup)
Here is the code:
    std::string str = "hello";
    std::vector<unsigned char> vec(str.begin(), str.end());

    auto b64val = utility::conversions::to_base64(vec); // Convert "hello" to base64

    auto urlval = http::uri::encode_data_string(b64val); // URL encode the base64 encoded value
Here, the original string is "hello"
Base64 encoded value is "aGVsbG8="
After URL encoding, the string returned is "aGVsbG8%3D" => The '=' has been encoded to '%3D'

Do you have a specific example where this is not working?
Oct 4, 2013 at 9:45 AM
Sorry, I must have used the wrong function when I was debugging another issue. It seems to be working!