diff --git a/src/morse.cpp b/src/morse.cpp index 819a26a..9b8a5ec 100644 --- a/src/morse.cpp +++ b/src/morse.cpp @@ -22,26 +22,26 @@ std::map morseCode = { std::string refurbishMessage(const std::string &msg) { - std::string msgUpper; - msgUpper.resize(msg.length()); + std::string msgRefurb; + msgRefurb.resize(msg.length()); // Make the message all upper case - std::transform(msg.cbegin(), msg.cend(), msgUpper.begin(), [](unsigned char c) { return std::toupper(c); }); + std::transform(msg.cbegin(), msg.cend(), msgRefurb.begin(), [](unsigned char c) { return std::toupper(c); }); // Encode the special characters as we like it - msgUpper = std::regex_replace(msgUpper, std::regex(""), "="); - msgUpper = std::regex_replace(msgUpper, std::regex(""), "k"); - msgUpper = std::regex_replace(msgUpper, std::regex(""), "s"); - msgUpper = std::regex_replace(msgUpper, std::regex(""), "+"); - msgUpper = std::regex_replace(msgUpper, std::regex(""), "a"); + msgRefurb = std::regex_replace(msgRefurb, std::regex(""), "="); + msgRefurb = std::regex_replace(msgRefurb, std::regex(""), "k"); + msgRefurb = std::regex_replace(msgRefurb, std::regex(""), "s"); + msgRefurb = std::regex_replace(msgRefurb, std::regex(""), "+"); + msgRefurb = std::regex_replace(msgRefurb, std::regex(""), "a"); // Remove all other unknown characters - msgUpper.erase(remove_if(msgUpper.begin(), msgUpper.end(), + msgRefurb.erase(remove_if(msgRefurb.begin(), msgRefurb.end(), [](const char &c) { return c != ' ' && morseCode.find(c) == morseCode.end(); }), - msgUpper.end()); + msgRefurb.end()); // Remove spaces, if there are too many of them - msgUpper = std::regex_replace(msgUpper, std::regex("(\\s+)"), " "); + msgRefurb = std::regex_replace(msgRefurb, std::regex("(\\s+)"), " "); - return msgUpper; + return msgRefurb; } \ No newline at end of file