diff --git a/source/common/utils.cpp b/source/common/utils.cpp index df6a3dd..1b2309f 100644 --- a/source/common/utils.cpp +++ b/source/common/utils.cpp @@ -367,7 +367,6 @@ bool checkCollision(SDL_Point &p, d_line_t &l) // En caso contrario, el punto está en la linea return true; - /*const int m = (l.y2 - l.y1) / (l.x2 - l.x1); const int c = 0; @@ -575,4 +574,20 @@ std::string boolToString(bool value) { return "false"; } +} + +// Convierte una cadena a minusculas +std::string toLower(std::string str) +{ + char *original = str.c_str(); + char *lower = (char *)malloc(str.size() + 1); + for (int i = 0; i < str.size(); ++i) + { + char c = original[i]; + lower[i] = (c >= 65 || c <= 90) ? c + 32 : c; + } + lower[str.size()] = 0; + std::string nova(lower); + free(lower); + return nova; } \ No newline at end of file diff --git a/source/common/utils.h b/source/common/utils.h index f4172e8..9e42760 100644 --- a/source/common/utils.h +++ b/source/common/utils.h @@ -200,4 +200,7 @@ bool stringToBool(std::string str); // Convierte un valor booleano en una cadena std::string boolToString(bool value); +// Convierte una cadena a minusculas +std::string toLower(std::string str); + #endif \ No newline at end of file