-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcpptool_main.cpp
More file actions
64 lines (49 loc) · 1.82 KB
/
cpptool_main.cpp
File metadata and controls
64 lines (49 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "cpptool.h"
#include "stringx/stringx.h"
void test_stringx()
{
split_result* res = string_split_result("123abc123edfgh123ijklm123nop123qrsvx123", "123", 0);
char* temp;
while (iterate_split_result(res, &temp))
{
puts(temp);
}
free_split_result(res);
printf("%s\n", boolToStr(string_equal("test_txt", "test_txt")));
printf("%s\n", string_clone("test_txt"));
printf("%s\n", string_join("中文_", string_join("test_txt", "_hehe")));
printf("%s\n", boolToStr(string_isNullOrEmpty("test.txt")));
printf("%s\n", boolToStr(string_isNullOrEmpty("")));
printf("%s\n", boolToStr(string_isNullOrEmpty(NULL)));
printf("%s\n", string_trim(" test _ txt "));
printf("%s %s\n", boolToStr(string_endsWith("test.txt", "txt")), boolToStr(string_endsWith("test.txt", "txxdxt")));
printf("%s %s\n", boolToStr(string_startsWith("test.txt", "test")), boolToStr(string_startsWith("test.txt", "1test")));
printf("%s\n", string_replace("123abc123edfgh123ijklm123nop123qrsvx123", "123", "你是猪"));
printf("%s\n", string_toLower("WWW.BAIDU.COM"));
printf("%s\n", string_toUpper("www.baidu.com"));
//抑或加密
char p[1024] = { 0 };;//只能使用非const
strcpy(p, "www.baidu.com");
printf("%s\n", string_XORcypher(p, "java"));
//随机字符串
printf("%s\n", string_random(15));
printf("%s\n", string_htmlEncode("www.baidu.com"));
printf("%s\n", string_urlEncode("www.baidu.com"));
}
void test_cpptool()
{
cout << transform(10, 2, "1024") << endl;
cout << transform(10, 16, "1024") << endl;
cout << transform(10, 8, "1024") << endl;
cout << transform(8, 10, "1024") << endl;
cout << transform(8, 16, "1024") << endl;
cout << transform(16, 10, "1024") << endl;
cout << transform(2, 10, "10000010") << endl;
cout << transform(2, 16, "10000010") << endl;
}
int main(int argc, char *argv[])
{
test_stringx();
test_cpptool();
return 0;
}