Request UTF-8 code page at startup on windows
This makes the *A Win32 API variants work correctly with UTF-8 parameters, which is nice because standard C/C++ facilities use those (because microsoft's libc is a steaming pile of microsoft code). OF COURSE this only works on win10 1903 and above. See https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page
This commit is contained in:
parent
7ef02a6c0b
commit
18084d5aa0
@ -60,6 +60,7 @@ if host_platform == 'windows'
|
||||
],
|
||||
depend_files: [
|
||||
'resource.h',
|
||||
'winutf8.xml',
|
||||
],
|
||||
)
|
||||
elif host_platform == 'darwin'
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "resource.h"
|
||||
#include <winuser.h>
|
||||
|
||||
IDI_ICON ICON DISCARDABLE "icon_exe.ico"
|
||||
IDI_DOC_ICON ICON DISCARDABLE "icon_cps.ico"
|
||||
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "winutf8.xml"
|
||||
|
8
resources/winutf8.xml
Normal file
8
resources/winutf8.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity name="." version="6.0.0.0"/>
|
||||
<application>
|
||||
<windowsSettings>
|
||||
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</assembly>
|
@ -7,6 +7,7 @@
|
||||
#include <iostream>
|
||||
#include <sys/stat.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#include <windows.h>
|
||||
@ -398,6 +399,10 @@ void UpdateCleanup()
|
||||
|
||||
void SetupCrt()
|
||||
{
|
||||
_setmode(0, _O_BINARY);
|
||||
_setmode(1, _O_BINARY);
|
||||
SetConsoleCP(CP_UTF8);
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
|
||||
|
Loading…
Reference in New Issue
Block a user