From 750a9483d169bdc10ab6865492b9e399e40bc20c Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Fri, 18 Aug 2023 12:25:52 +0000 Subject: common: Windows Unicode CLI support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows CLI arguments use either ANSI (main()) or UTF-16 (wmain()). Meanwhile, Ceph libraries expect UTF-8 and raise exceptions when trying to use Unicode CLI arguments or log Unicode output: rbd.exe create test_unicode_șțăâ --size=32M terminate called after throwing an instance of 'std::runtime_error' what(): invalid utf8 We'll use a Windows application manifest, setting the "activeCodePage" property [1][2]. This enables the Windows UCRT UTF-8 mode so that functions that receive char* arguments will expect UTF-8 instead of ANSI, including main(). One exception is CreateProcess, which will need the UTF-16 form (CreateProcessW). Despite the locale being set to utf-8, we'll have to explicitly set the console output to utf-8 using SetConsoleOutputCP(CP_UTF8). In order to use the UTF-8 locale, we'll have to switch the mingw-llvm runtime from msvcrt to ucrt. This also fixes ceph-dokan crashes that currently occur when non-ANSI paths are logged. [1] https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#activecodepage [2] https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page Signed-off-by: Lucian Petrut --- win32_deps_build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'win32_deps_build.sh') diff --git a/win32_deps_build.sh b/win32_deps_build.sh index 6eea81d1b8a..c61cd7cb78a 100755 --- a/win32_deps_build.sh +++ b/win32_deps_build.sh @@ -40,8 +40,8 @@ dokanTag="v2.0.5.1000" dokanSrcDir="${depsSrcDir}/dokany" dokanLibDir="${depsToolsetDir}/dokany/lib" -mingwLlvmUrl="https://github.com/mstorsjo/llvm-mingw/releases/download/20230320/llvm-mingw-20230320-msvcrt-ubuntu-18.04-x86_64.tar.xz" -mingwLlvmSha256Sum="bc97745e702fb9e8f2a16f7d09dd5061ceeef16554dd12e542f619ce937e8d7a" +mingwLlvmUrl="https://github.com/mstorsjo/llvm-mingw/releases/download/20230320/llvm-mingw-20230320-ucrt-ubuntu-18.04-x86_64.tar.xz" +mingwLlvmSha256Sum="bc367753dea829d219be32e2e64e2d15d03158ce8e700ae5210ca3d78e6a07ea" mingwLlvmDir="${DEPS_DIR}/mingw-llvm" function _make() { -- cgit v1.2.3