factored out to_hex into the escape_string header file

This commit is contained in:
Arvid Norberg
2008-05-19 07:36:04 +00:00
parent 8613554c2a
commit 07f070868d
4 changed files with 33 additions and 29 deletions

View File

@@ -352,5 +352,17 @@ namespace libtorrent
return url.substr(pos, url.find('&', pos) - pos);
}
TORRENT_EXPORT std::string to_hex(std::string const& s)
{
std::string ret;
char* digits = "0123456789abcdef";
for (std::string::const_iterator i = s.begin(); i != s.end(); ++i)
{
ret += digits[((unsigned char)*i) >> 4];
ret += digits[((unsigned char)*i) & 0xf];
}
return ret;
}
}