mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Escape more strings: formspecs, item descriptions, infotexts...
Also, change the escape character to the more standard \x1b Thus, it can be used in the future for translation or colored text, for example.
This commit is contained in:
parent
21079cc8eb
commit
48939df9a5
8 changed files with 105 additions and 83 deletions
|
@ -729,33 +729,6 @@ static bool parseNamedColorString(const std::string &value, video::SColor &color
|
|||
return true;
|
||||
}
|
||||
|
||||
std::wstring removeChatEscapes(const std::wstring &s) {
|
||||
std::wstring output;
|
||||
size_t i = 0;
|
||||
while (i < s.length()) {
|
||||
if (s[i] == L'\v') {
|
||||
++i;
|
||||
if (i == s.length()) continue;
|
||||
if (s[i] == L'(') {
|
||||
++i;
|
||||
while (i < s.length() && s[i] != L')') {
|
||||
if (s[i] == L'\\') {
|
||||
++i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
++i;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
output += s[i];
|
||||
++i;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
void str_replace(std::string &str, char from, char to)
|
||||
{
|
||||
std::replace(str.begin(), str.end(), from, to);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue