Added support for some XML entities in add-ons description

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9060 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2011-06-25 22:38:19 +00:00
parent 8bd6a8a4c0
commit 9f33ff77e8
3 changed files with 44 additions and 0 deletions
+31
View File
@@ -443,6 +443,37 @@ namespace StringUtils
return std::string(s);
} // timeToString
// ------------------------------------------------------------------------
std::string replace(const std::string& other, const std::string& from, const std::string& to)
{
std::string wip = other;
while (true)
{
const int pos = wip.find(from);
if (pos == -1)
{
return wip;
}
wip.replace(pos, from.size(), to.c_str(), to.size());
}
/*
// found this on google... looks good but doesn't work, it leaves out some occurrences,
// didn't search why
std::string::size_type next;
for (next = wip.find(from); next != std::string::npos; next = wip.find(from, next))
{
wip.replace(next, from.length(), to);
next += from.length();
}
return wip;
*/
}
} // namespace StringUtils
/* EOF */