util: Migrated obfuscateText from text
This commit is contained in:
33
src/util.cpp
33
src/util.cpp
@@ -54,6 +54,7 @@
|
||||
|
||||
#include <Lexer.h>
|
||||
#include <text.h>
|
||||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
#include <i18n.h>
|
||||
|
||||
@@ -283,3 +284,35 @@ std::string osName ()
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string obfuscateText (const std::string& input)
|
||||
{
|
||||
std::stringstream output;
|
||||
std::string::size_type i = 0;
|
||||
int character;
|
||||
bool inside = false;
|
||||
|
||||
while ((character = utf8_next_char (input, i)))
|
||||
{
|
||||
if (inside)
|
||||
{
|
||||
output << (char) character;
|
||||
|
||||
if (character == 'm')
|
||||
inside = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (character == 033)
|
||||
inside = true;
|
||||
|
||||
if (inside || character == ' ')
|
||||
output << (char) character;
|
||||
else
|
||||
output << 'x';
|
||||
}
|
||||
}
|
||||
|
||||
return output.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user