-
Notifications
You must be signed in to change notification settings - Fork 151
/
StringHelper.h
132 lines (96 loc) · 1.99 KB
/
StringHelper.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#pragma once
#include <Windows.h>
//计算字符串长度
int __fastcall StrLen(
_In_opt_z_ LPCSTR psz
);
int __fastcall StrLen(
_In_opt_z_ LPCWSTR psz
);
#define StaticStrLen(str) (ArraySize(str)-1)
#define StrEmpty(str) ((str==NULL)||(*str==NULL))
//static LPWSTR StrSpet(LPCWSTR Str)
#define StrSpet(Str) (LPWSTR)(Str + StrLen(Str) + 1)
//过滤指定字符
LPCWSTR StrFilter(
_In_z_ LPCWSTR SrcStr,
_In_z_ LPCWSTR IgnoreStr
);
//过滤不可见字符
//LPCWSTR StrFilterNotVisible(LPCWSTR Str)
#define StrFilterNotVisible(Str) StrFilter(Str, L" \t\r\n\xFEFF")
//获取指定字符串
bool StrGet(
_Inout_z_ LPCWSTR& _Str,
_In_z_ LPCWSTR EndStr,
_In_opt_ LPCWSTR ErrorStr,
_Out_ CString& data
);
LPCWSTR StrExistI(
_In_z_ LPCWSTR Str,
_In_z_ LPCWSTR Find
);
//void StrAppend(BSTR& Str, LPCWSTR Append);
size_t StrRemove(
_In_z_ LPWSTR RemoveStr
);
CString StrFormat(
_In_z_ _Printf_format_string_ LPCWSTR Format, ...
);
void StrDelete(
_Inout_ CString& Scr,
_In_z_ LPCWSTR Dst
);
CString Str2MultiStr(
_In_z_ LPCWSTR Str
);
//将字节数按字符输出
CString StrFormatByte(
_In_ LONGLONG ByteSize
);
CStringA Unicode2UTF8(
_In_z_ LPCWSTR Str
);
CStringA Unicode2UTF8(
_In_NLS_string_(cStr) LPCWSTR Str,
_In_ DWORD cStr
);
void UTF8ToUnicode(
_In_NLS_string_(cchSrc) const char* Src,
_In_ DWORD cchSrc,
_Out_ CString& Dest
);
CString UTF8ToUnicode(
_In_NLS_string_(cchSrc) const char* Src,
_In_ DWORD cchSrc
);
CString UTF8ToUnicode(
_In_z_ const char* Src
);
BOOL StrRegexMatch(
_In_z_ LPCWSTR Str,
_In_z_ LPCWSTR MatchStr
);
CString Guid2Str(
_In_ const GUID& guid
);
bool Str2Guid(
_In_z_ LPCWSTR String,
_Out_ GUID& Guid
);
bool Str2Guid(
_In_z_ LPCSTR String,
_Out_ GUID& Guid
);
GUID Str2Guid(
_In_z_ LPCWSTR String
);
CString StrCut(
_In_ CString String,
_In_ DWORD MaxLen,
_In_ wchar_t ch = L'.'
);
//"\0\0"结束
DWORD MultiStrLen(
_In_ LPCWSTR String
);