Added encoding of special characters when writing
addons_installed.xml. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9511 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -475,8 +475,11 @@ namespace StringUtils
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
irr::core::stringw removeHtmlEntities(const std::string& input)
|
||||
/** Converts ASCII text with HTML entities (e.g. &xE9;) to unicode strings
|
||||
* \param input The input string which should be decoded.
|
||||
* \return A irrlicht wide string with unicode characters.
|
||||
*/
|
||||
irr::core::stringw decodeFromHtmlEntities(const std::string& input)
|
||||
{
|
||||
irr::core::stringw output;
|
||||
std::string entity;
|
||||
@@ -555,8 +558,36 @@ namespace StringUtils
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
} // decodeFromHtmlEntities
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Converts a unicode string to plain ASCII using html-like & codes.
|
||||
* \param s The input string which should be encoded.
|
||||
* \return A std:;string with ASCII characters.
|
||||
*/
|
||||
std::string encodeToHtmlEntities(const irr::core::stringw &s)
|
||||
{
|
||||
std::ostringstream output;
|
||||
for(unsigned int i=0; i<s.size(); i++)
|
||||
{
|
||||
if(s[i]=='&')
|
||||
output<<"&";
|
||||
else
|
||||
{
|
||||
if(s[i]<128)
|
||||
{
|
||||
irr::c8 c=(char)(s[i]);
|
||||
output<<c;
|
||||
}
|
||||
else
|
||||
{
|
||||
output <<"&#" << std::hex <<std::uppercase<< s[i]<<";";
|
||||
}
|
||||
}
|
||||
}
|
||||
return output.str();
|
||||
} // encodeToHtmlEntities
|
||||
|
||||
} // namespace StringUtils
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user