From 5951bc76ec8fbb188777de66cb965f05446c7f38 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 7 Jul 2013 14:42:07 +0000 Subject: Added StringUtils functions to Lua API; added StripColorCodes(); ChatLog now strips color codes from logged messages. Fixes FS #398 git-svn-id: http://mc-server.googlecode.com/svn/trunk@1661 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/StringUtils.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'source/StringUtils.cpp') diff --git a/source/StringUtils.cpp b/source/StringUtils.cpp index 2bb6ae76e..403b10a7c 100644 --- a/source/StringUtils.cpp +++ b/source/StringUtils.cpp @@ -594,8 +594,8 @@ AString EscapeString(const AString & a_Message) last = i + 1; break; } - } - } + } // switch (ch) + } // for i - a_Message[] if (len > last) { EscapedMsg.append(a_Message, last, len - last); @@ -606,3 +606,22 @@ AString EscapeString(const AString & a_Message) + +AString StripColorCodes(const AString & a_Message) +{ + AString res(a_Message); + size_t idx = 0; + while (true) + { + idx = res.find("\xc2\xa7", idx); + if (idx == AString::npos) + { + return res; + } + res.erase(idx, 3); + } +} + + + + -- cgit v1.2.3