Add string function to strip all SCC characters
This commit is contained in:
@@ -357,6 +357,28 @@ void str_strip_colours(char *str)
|
|||||||
*dst = '\0';
|
*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
|
/** Scans the string for a wchar and replace it with another wchar
|
||||||
* @param str The string buffer
|
* @param str The string buffer
|
||||||
* @param last The pointer to the last element of the string buffer
|
* @param last The pointer to the last element of the string buffer
|
||||||
|
@@ -48,6 +48,7 @@ void ValidateString(const char *str);
|
|||||||
|
|
||||||
const char *str_fix_scc_encoded(char *str, const char *last);
|
const char *str_fix_scc_encoded(char *str, const char *last);
|
||||||
void str_strip_colours(char *str);
|
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);
|
char *str_replace_wchar(char *str, const char *last, WChar find, WChar replace);
|
||||||
bool strtolower(char *str);
|
bool strtolower(char *str);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user