I use a function that I found in this question, adapted to replace all spaces with "%20" (probably could be done far more efficiently!):
## Heading ##std::string Main::SpacesForWeb(std::string text) {
for (std::string::iterator it = text.begin(); it != text.end(); ++it) {
if (*it == ' ') {
*it = '%20';
}
}
return text;
}
However when I try to use it for a string such as Local Live Test Server
, the output is this:
My last question dealt with string
issues and found out that string
is typedef
ed to point to the internal CryString
type in the game SDK I am using (CryEngine2). I am now using std::string
in order to counter this.
This issue is also reflected in the database I use after this conversion happens and the data is sent to the database:
Why can't I use %20
(and perhaps other URL encoding symbols) in this way, and how can I get this to work?
I attempted to do some research on this in order to fix the issue myself, but however nothing relevant came up.
I have tried using *it = (char)"%20";
in-place of *it = (char)"%20";
, but however this actually removes the 0
that is appearing in the string instead of replacing the spaces with %20
.