summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/string_util.cpp16
-rw-r--r--src/common/string_util.h5
2 files changed, 9 insertions, 12 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index c1f22bda3..c489c868b 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -18,19 +18,15 @@
18#endif 18#endif
19 19
20/// Make a string lowercase 20/// Make a string lowercase
21void LowerStr(char* str) { 21std::string LowerStr(std::string str) {
22 for (int i = 0; str[i]; i++) { 22 std::transform(str.begin(), str.end(), str.begin(), ::tolower);
23 str[i] = tolower(str[ i ]); 23 return str;
24 }
25} 24}
26 25
27/// Make a string uppercase 26/// Make a string uppercase
28void UpperStr(char* str) { 27std::string UpperStr(std::string str) {
29 for (int i=0; i < strlen(str); i++) { 28 std::transform(str.begin(), str.end(), str.begin(), ::toupper);
30 if(str[i] >= 'a' && str[i] <= 'z') { 29 return str;
31 str[i] &= 0xDF;
32 }
33 }
34} 30}
35 31
36// faster than sscanf 32// faster than sscanf
diff --git a/src/common/string_util.h b/src/common/string_util.h
index ba4cd363e..b1118816e 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -13,10 +13,11 @@
13#include "common/common.h" 13#include "common/common.h"
14 14
15/// Make a string lowercase 15/// Make a string lowercase
16void LowerStr(char* str); 16
17std::string LowerStr(std::string str);
17 18
18/// Make a string uppercase 19/// Make a string uppercase
19void UpperStr(char* str); 20std::string UpperStr(std::string str);
20 21
21std::string StringFromFormat(const char* format, ...); 22std::string StringFromFormat(const char* format, ...);
22// Cheap! 23// Cheap!