diff options
| -rw-r--r-- | src/common/string_util.cpp | 16 | ||||
| -rw-r--r-- | src/common/string_util.h | 6 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index a99644f11..e5a9ba322 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -17,6 +17,22 @@ | |||
| 17 | #include <errno.h> | 17 | #include <errno.h> |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | /// Make a string lowercase | ||
| 21 | void LowerStr(char* str) { | ||
| 22 | for (int i = 0; str[i]; i++) { | ||
| 23 | str[i] = tolower(str[ i ]); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | /// Make a string uppercase | ||
| 28 | void UpperStr(char* str) { | ||
| 29 | for (int i=0; i < strlen(str); i++) { | ||
| 30 | if(str[i] >= 'a' && str[i] <= 'z') { | ||
| 31 | str[i] &= 0xDF; | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 20 | // faster than sscanf | 36 | // faster than sscanf |
| 21 | bool AsciiToHex(const char* _szValue, u32& result) | 37 | bool AsciiToHex(const char* _szValue, u32& result) |
| 22 | { | 38 | { |
diff --git a/src/common/string_util.h b/src/common/string_util.h index 6b7e84797..b3c99a807 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h | |||
| @@ -14,6 +14,12 @@ | |||
| 14 | 14 | ||
| 15 | #include "common/common.h" | 15 | #include "common/common.h" |
| 16 | 16 | ||
| 17 | /// Make a string lowercase | ||
| 18 | void LowerStr(char* str); | ||
| 19 | |||
| 20 | /// Make a string uppercase | ||
| 21 | void UpperStr(char* str); | ||
| 22 | |||
| 17 | std::string StringFromFormat(const char* format, ...); | 23 | std::string StringFromFormat(const char* format, ...); |
| 18 | // Cheap! | 24 | // Cheap! |
| 19 | bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args); | 25 | bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args); |