summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGangzheng Tong <tonggangzheng@gmail.com>2025-09-08 10:24:05 -0700
committerGitHub <noreply@github.com>2025-09-08 17:24:05 +0000
commit3aff764c2b5d613f766538d27e0b9f448e7ed5ca (patch)
tree0d21cd8486bb8914a933cd58841e4c9bb246df70 /tools
parent8b512c49d163af1df33e940acc3c4a230f0d00b7 (diff)
Use wide char version of Windows API (#8390)
This PR modernizes the Windows-specific code by replacing ANSI Windows API functions with their Unicode (wide character) counterparts. This change ensures proper handling of Unicode file paths and strings on Windows systems. ### File Operations (`source/core/slang-io.cpp`) - `DeleteFileA` → `DeleteFileW` - `GetTempPathA` → `GetTempPathW` - `GetTempFileNameA` → `GetTempFileNameW` - `RemoveDirectoryA` → `RemoveDirectoryW` - `SHFileOperationA` → `SHFileOperationW` - `GetModuleFileNameA` → `GetModuleFileNameW` with UTF-8 conversion ### Platform Operations (`source/core/slang-platform.cpp`) - `GetModuleHandleExA` → `GetModuleHandleExW` - `LoadLibraryExA` → `LoadLibraryExW` - `LoadLibraryA` → `LoadLibraryW` - `OutputDebugStringA` → `OutputDebugStringW` ### Runtime and Tools - `MessageBoxA` → `MessageBoxW` in slang-rt - `GetCurrentDirectoryA` → `GetCurrentDirectoryW` in slang-fiddle - String literal conversion to wide strings in vk-pipeline-create --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Gangzheng Tong <gtong-nv@users.noreply.github.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/slang-fiddle/slang-fiddle-main.cpp9
-rw-r--r--tools/vk-pipeline-create/main.cpp4
2 files changed, 8 insertions, 5 deletions
diff --git a/tools/slang-fiddle/slang-fiddle-main.cpp b/tools/slang-fiddle/slang-fiddle-main.cpp
index cf8407995..fea16dafe 100644
--- a/tools/slang-fiddle/slang-fiddle-main.cpp
+++ b/tools/slang-fiddle/slang-fiddle-main.cpp
@@ -425,9 +425,12 @@ int main(int argc, char const* const* argv)
}
fprintf(stderr, "\n");
- char buffer[1024];
- GetCurrentDirectoryA(sizeof(buffer), buffer);
- fprintf(stderr, "cwd: %s\n", buffer);
+ wchar_t wideBuffer[1024];
+ GetCurrentDirectoryW(sizeof(wideBuffer) / sizeof(wideBuffer[0]), wideBuffer);
+
+ // Convert to UTF-8 using String::fromWString
+ String currentDir = String::fromWString(wideBuffer);
+ fprintf(stderr, "cwd: %s\n", currentDir.getBuffer());
return 1;
#endif
diff --git a/tools/vk-pipeline-create/main.cpp b/tools/vk-pipeline-create/main.cpp
index 91abb90bc..5685affb4 100644
--- a/tools/vk-pipeline-create/main.cpp
+++ b/tools/vk-pipeline-create/main.cpp
@@ -278,8 +278,8 @@ void PipelineCreationReplay::initVulkanAPI(IDevice* device)
vkAPI.device = (VkDevice)(handle.handles[2].value);
vkAPI.instance = (VkInstance)(handle.handles[0].value);
#if SLANG_WINDOWS_FAMILY
- auto dynamicLibraryName = "vulkan-1.dll";
- HMODULE module = ::LoadLibraryA(dynamicLibraryName);
+ auto dynamicLibraryName = L"vulkan-1.dll";
+ HMODULE module = ::LoadLibraryW(dynamicLibraryName);
vkAPI.vulkanLibraryHandle = (void*)module;
#define VK_API_GET_GLOBAL_PROC(x) vkAPI.x = (PFN_##x)GetProcAddress(module, #x);
#else