-
Notifications
You must be signed in to change notification settings - Fork 0
/
wstring.h
97 lines (74 loc) · 2.52 KB
/
wstring.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
#ifndef __WSTRING_H
#define __WSTRING_H
#include <windows.h>
///////////////////////////////////////////////////////////////////////////////
//
// copies a single byte string to a unicode string
//
// param: str - buffer for single byte string
// wStr - unicode string
//
// return: success - not null
// failure - null
//
///////////////////////////////////////////////////////////////////////////////
int MBTWC(LPSTR str, LPWSTR wStr, int size);
///////////////////////////////////////////////////////////////////////////////
//
// copies a unicode string to a single byte string
//
// param: wStr - unicode string
// str - buffer for single byte string
//
// return: success - not null
// failure - null
//
///////////////////////////////////////////////////////////////////////////////
int WCTMB(LPWSTR wStr, LPSTR str, int size);
///////////////////////////////////////////////////////////////////////////////
//
// allocates memory for a unicode string and copies a single byte string to a
// unicode string
//
// param: str - single byte string
// strLen - length of str or -1 if str is null terminated
//
// return: success - unicode string (must be deallocated with FreeStr)
// failure - null
//
///////////////////////////////////////////////////////////////////////////////
PWSTR S2W(PSTR str, int strLen = -1);
///////////////////////////////////////////////////////////////////////////////
//
// allocates memory for a single byte string and copies a unicode string to a
// single byte string
//
// param: wStr - unicode string
// strLen - length of wStr or -1 if wStr is null terminated
//
// return: success - single byte string (must be deallocated with FreeStr)
// failure - null
//
///////////////////////////////////////////////////////////////////////////////
PSTR W2S(PWSTR wStr, int strLen = -1);
///////////////////////////////////////////////////////////////////////////////
//
// frees a single byte string
//
// param: str - single byte string
//
// return: nothing
//
///////////////////////////////////////////////////////////////////////////////
void FreeStr(PSTR str);
///////////////////////////////////////////////////////////////////////////////
//
// frees a unicode string
//
// param: wStr - unicode string
//
// return: nothing
//
///////////////////////////////////////////////////////////////////////////////
void FreeStr(PWSTR wStr);
#endif