Url Encode SMS messages.

This commit is contained in:
Arthur Britto
2013-03-30 01:00:00 -07:00
parent 58b3cc1dd6
commit c67366ea25
3 changed files with 37 additions and 3 deletions

View File

@@ -187,6 +187,38 @@ std::string strCopy(const std::vector<unsigned char>& vucSrc)
}
extern std::string urlEncode(const std::string& strSrc)
{
std::string strDst;
int iOutput = 0;
int iSize = strSrc.length();
strDst.resize(iSize*3);
for (int iInput = 0; iInput < iSize; iInput++) {
unsigned char c = strSrc[iInput];
if (c == ' ')
{
strDst[iOutput++] = '+';
}
else if (isalnum(c))
{
strDst[iOutput++] = c;
}
else
{
strDst[iOutput++] = '%';
strDst[iOutput++] = charHex(c >> 4);
strDst[iOutput++] = charHex(c & 15);
}
}
strDst.resize(iOutput);
return strDst;
}
//
// DH support
//