Skip to content

Commit

Permalink
Merge pull request #48 from ArthanIRC/message-chars
Browse files Browse the repository at this point in the history
feat: new locale to allow utf8 chars
  • Loading branch information
mortebrume authored Sep 5, 2024
2 parents 26bd73f + 55c3f50 commit df792e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <cctype>
#include <cstddef>
#include <cstdio>
#include <locale>
#include <sstream>
#include <vector>

Expand Down Expand Up @@ -85,6 +86,9 @@ int Message::parse(string& data, string& source, string& command,

bool Message::validate(const string& source, const string& command,
const vector<string>& params) {

std::locale loc("en_US.UTF-8");

if (!source.empty()) {
for (size_t i = 0; i < source.length(); ++i) {
if (!std::isalnum(source[i]) && source[i] != '-' &&
Expand All @@ -111,7 +115,7 @@ bool Message::validate(const string& source, const string& command,

for (size_t i = 0; i < params.size(); ++i) {
for (size_t j = 0; j < params[i].length(); ++j) {
if (!std::isprint(params[i][j])) {
if (!std::isprint(params[i][j], loc)) {
return (false);
}
}
Expand Down

0 comments on commit df792e8

Please sign in to comment.