mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Url Encode SMS messages.
This commit is contained in:
@@ -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
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user