From e41951c43a8f6a0bcf6b0fcceebec99f87f7d1e7 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 10 Dec 2024 22:22:44 -0500 Subject: Support building for Windows with or without UNICODE --- src/win32/win32_util.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/win32/win32_util.h (limited to 'src/win32/win32_util.h') diff --git a/src/win32/win32_util.h b/src/win32/win32_util.h new file mode 100644 index 0000000..3123ef4 --- /dev/null +++ b/src/win32/win32_util.h @@ -0,0 +1,31 @@ +// Copyright 2019-2024 David Robillard +// SPDX-License-Identifier: ISC + +#ifndef ZIX_WIN32_UTIL_H +#define ZIX_WIN32_UTIL_H + +#include + +#ifdef UNICODE +typedef wchar_t ArgPathChar; +#else +typedef const char ArgPathChar; +#endif + +/// Copy and convert a path argument if necessary +ArgPathChar* +arg_path_new(ZixAllocator* const allocator, const char* const path); + +/// Free a path from arg_path_new() if necessary +void +arg_path_free(ZixAllocator* const allocator, ArgPathChar* const path); + +/// Convert from (user) UTF-8 to (Windows) UTF-16 +wchar_t* +zix_utf8_to_wchar(ZixAllocator* allocator, const char* utf8); + +/// Convert from (Windows) UTF-16 to (user) UTF-8 +char* +zix_wchar_to_utf8(ZixAllocator* allocator, const wchar_t* wstr); + +#endif // ZIX_WIN32_UTIL_H -- cgit v1.2.1