Add string function to strip all SCC characters

This commit is contained in:
Jonathan G Rennison
2020-12-16 02:04:57 +00:00
parent 207c79a736
commit d328f359c9
2 changed files with 23 additions and 0 deletions

View File

@@ -357,6 +357,28 @@ void str_strip_colours(char *str)
*dst = '\0';
}
std::string str_strip_all_scc(const char *str)
{
std::string out;
if (!str) return out;
WChar c;
size_t len;
for (len = Utf8Decode(&c, str); c != '\0'; len = Utf8Decode(&c, str)) {
if (c < SCC_CONTROL_START || c > SCC_SPRITE_END) {
/* Copy the characters */
do {
out.push_back(*str++);
} while (--len != 0);
} else {
/* Just skip (strip) the control codes */
str += len;
}
}
return out;
}
/** Scans the string for a wchar and replace it with another wchar
* @param str The string buffer
* @param last The pointer to the last element of the string buffer

View File

@@ -48,6 +48,7 @@ void ValidateString(const char *str);
const char *str_fix_scc_encoded(char *str, const char *last);
void str_strip_colours(char *str);
std::string str_strip_all_scc(const char *str);
char *str_replace_wchar(char *str, const char *last, WChar find, WChar replace);
bool strtolower(char *str);