Skip to content

Commit a18622c

Browse files
committedFeb 10, 2025
TextLinkOpenURL(): fixed default Win32 io.PlatformOpenInShellFn handler to handle UTF-8 regardless of system regional settings. (ocornut#7660)
1 parent 2206e31 commit a18622c

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed
 

‎docs/CHANGELOG.txt

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Other changes:
5757
which amusingly made it disappear when using very big font/frame size.
5858
- Tables: fixed calling SetNextWindowScroll() on clipped scrolling table
5959
to not leak the value into a subsequent window. (#8196)
60+
- TextLinkOpenURL(): fixed default Win32 io.PlatformOpenInShellFn handler to
61+
handle UTF-8 regardless of system regional settings. (#7660) [@achabense]
6062
- Demo: Combos: demonstrate a very simple way to add a filter to a combo,
6163
by showing the filter inside the combo contents. (#718)
6264
- Backends: Metal: Fixed a crash on application resources. (#8367, #7419) [@anszom]

‎imgui.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -15090,7 +15090,11 @@ static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext* ctx, const cha
1509015090
#endif
1509115091
static bool Platform_OpenInShellFn_DefaultImpl(ImGuiContext*, const char* path)
1509215092
{
15093-
return (INT_PTR)::ShellExecuteA(NULL, "open", path, NULL, NULL, SW_SHOWDEFAULT) > 32;
15093+
const int path_wsize = ::MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
15094+
ImVector<wchar_t> path_wbuf;
15095+
path_wbuf.resize(path_wsize);
15096+
::MultiByteToWideChar(CP_UTF8, 0, path, -1, path_wbuf.Data, path_wsize);
15097+
return (INT_PTR)::ShellExecuteW(NULL, L"open", path_wbuf.Data, NULL, NULL, SW_SHOWDEFAULT) > 32;
1509415098
}
1509515099
#else
1509615100
#include <sys/wait.h>

‎imgui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3565,7 +3565,7 @@ struct ImGuiPlatformIO
35653565
void* Platform_ClipboardUserData;
35663566

35673567
// Optional: Open link/folder/file in OS Shell
3568-
// (default to use ShellExecuteA() on Windows, system() on Linux/Mac)
3568+
// (default to use ShellExecuteW() on Windows, system() on Linux/Mac)
35693569
bool (*Platform_OpenInShellFn)(ImGuiContext* ctx, const char* path);
35703570
void* Platform_OpenInShellUserData;
35713571

‎imgui_demo.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -7771,6 +7771,9 @@ void ImGui::ShowAboutWindow(bool* p_open)
77717771
#ifdef IMGUI_DISABLE_WIN32_FUNCTIONS
77727772
ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS");
77737773
#endif
7774+
#ifdef IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS
7775+
ImGui::Text("define: IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS");
7776+
#endif
77747777
#ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
77757778
ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS");
77767779
#endif

0 commit comments

Comments
 (0)