forked from tsilia/ext4tc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
47 lines (39 loc) · 1.13 KB
/
Copy pathutils.cpp
File metadata and controls
47 lines (39 loc) · 1.13 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
#include <windows.h>
#include "utils.h"
int MultibyteToMultibyte(UINT dwSrcCodePage, char *lpSrcStr, int cbSrcStr,
UINT dwDestCodePage, char *lpDestStr, int cbDestStr)
{
WCHAR *wzTemp = NULL;
int nSrcLen = 0;
if (dwSrcCodePage == dwDestCodePage)
{
return 0;
}
if (lpSrcStr == NULL)
{
return 0;
}
if (-1 == cbSrcStr)
{
nSrcLen = strlen(lpSrcStr) + 1;
}
else
{
nSrcLen = cbSrcStr;
}
if ((NULL == lpDestStr) || (0 == cbDestStr))
{
return nSrcLen;
}
wzTemp = new WCHAR[nSrcLen + 1];
if (NULL == wzTemp)
{
return 0;
}
memset(wzTemp, 0, (nSrcLen + 1) * sizeof(WCHAR));
MultiByteToWideChar(dwSrcCodePage, 0, lpSrcStr, cbSrcStr, wzTemp, nSrcLen);
nSrcLen = WideCharToMultiByte(dwDestCodePage, 0, wzTemp, -1, lpDestStr, cbDestStr, NULL, FALSE);
delete [] wzTemp;
wzTemp = NULL;
return nSrcLen;
}