mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Add function UnescapeMenuString
Turns E&dit into Edit and 'd'. Double ampersands are translated to just a single one, hence the unescaping part of this. Useful in the Mac port to deal with desktop UI translation strings with included Windows hotkeys.
This commit is contained in:
1 parent
3d7e73a37a
commit
91d4ded3fd
3 files changed
+49
No files matched your search
@@ -342,3 +342,27 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string UnescapeMenuString(const char *input, char *shortcutChar) {
|
||||
size_t len = strlen(input);
|
||||
std::string output;
|
||||
output.reserve(len);
|
||||
bool escaping = false;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
if (input[i] == '&') {
|
||||
if (escaping) {
|
||||
output.push_back(input[i]);
|
||||
escaping = false;
|
||||
} else {
|
||||
escaping = true;
|
||||
}
|
||||
} else {
|
||||
output.push_back(input[i]);
|
||||
if (escaping && shortcutChar) {
|
||||
*shortcutChar = input[i];
|
||||
}
|
||||
escaping = false;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
Reference in new issue
Block a user