Skip to content

Commit 44e1121

Browse files
committed
fix: 支持UTF8字符串
1 parent 8989956 commit 44e1121

File tree

6 files changed

+49
-2
lines changed

6 files changed

+49
-2
lines changed

ExplorerPatcher/ExplorerPatcher.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@
254254
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
255255
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
256256
</ClCompile>
257+
<ClCompile Include="helper.c" />
257258
<ClCompile Include="HideExplorerSearchBar.c" />
258259
<ClCompile Include="ImmersiveFlyouts.c">
259260
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
@@ -315,6 +316,7 @@
315316
<ClInclude Include="fmemopen.h" />
316317
<ClInclude Include="getline.h" />
317318
<ClInclude Include="GUI.h" />
319+
<ClInclude Include="helper.h" />
318320
<ClInclude Include="HideExplorerSearchBar.h" />
319321
<ClInclude Include="hooking.h" />
320322
<ClInclude Include="ep_private.h" />

ExplorerPatcher/ExplorerPatcher.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
<ClInclude Include="osutility.h">
133133
<Filter>Header Files\internal</Filter>
134134
</ClInclude>
135+
<ClInclude Include="helper.h">
136+
<Filter>Header Files</Filter>
137+
</ClInclude>
135138
</ItemGroup>
136139
<ItemGroup>
137140
<ResourceCompile Include="ExplorerPatcher.rc">
@@ -214,6 +217,9 @@
214217
<ClCompile Include="lvt.c">
215218
<Filter>Source Files</Filter>
216219
</ClCompile>
220+
<ClCompile Include="helper.c">
221+
<Filter>Source Files</Filter>
222+
</ClCompile>
217223
</ItemGroup>
218224
<ItemGroup>
219225
<None Include="settings.reg">

ExplorerPatcher/GUI.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
13451345
if (GetTimeFormatEx(wszWeatherLanguage[0] ? wszWeatherLanguage : wszLanguage, TIME_NOSECONDS, &stLastUpdate, NULL, wszTime, MAX_PATH))
13461346
{
13471347
bOk = TRUE;
1348-
swprintf_s(text, MAX_LINE_LENGTH, L"上一次更新: %s, %s.", wszDate, wszTime);
1348+
swprintf_s(text, MAX_LINE_LENGTH, Utf8Text("上一次更新: %s, %s."), wszDate, wszTime);
13491349
}
13501350
}
13511351
}
@@ -3145,7 +3145,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
31453145
1,
31463146
0
31473147
);
3148-
swprintf(text + 3, MAX_LINE_LENGTH, _TEXT("禁用应用切换列表( Alt + %c )"), key);
3148+
swprintf(text + 3, MAX_LINE_LENGTH, Utf8Text("禁用应用切换列表( Alt + %c )"), key);
31493149
}
31503150
if (tabOrder == _this->tabOrder)
31513151
{

ExplorerPatcher/GUI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
2828
#include "../ep_weather_host/ep_weather_host_h.h"
2929
#include <ExDisp.h>
3030
#include <ShlGuid.h>
31+
#include "helper.h"
3132

3233
#define MAX_LINE_LENGTH 2000
3334
extern HMODULE hModule;

ExplorerPatcher/helper.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "helper.h"
2+
3+
LPWSTR Utf8Text(LPCCH input)
4+
{
5+
//获取输入字符串大小
6+
// int bufSize = strlen(input);
7+
8+
//获取所需缓冲大小
9+
int cchSize = MultiByteToWideChar(
10+
CP_UTF8,
11+
MB_PRECOMPOSED,
12+
input,
13+
-1,
14+
NULL,
15+
0
16+
);
17+
18+
LPWSTR output = (wchar_t*)malloc(cchSize*sizeof(wchar_t));
19+
20+
MultiByteToWideChar(
21+
CP_UTF8,
22+
MB_PRECOMPOSED,
23+
input,
24+
-1,
25+
output,
26+
cchSize
27+
);
28+
29+
return output;
30+
}

ExplorerPatcher/helper.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef _H_HELPER_H_
2+
#define _H_HELPER_H_
3+
4+
#include <Windows.h>
5+
6+
LPWSTR Utf8Text(LPCCH input);
7+
8+
#endif

0 commit comments

Comments
 (0)