computer_tips:how_to_create_utf-8_winapi_application_using_mingw_toolchain
This is an old revision of the document!
How to create UTF-8 winapi application using mingw toolchain?
In addition to mingw you will need mt.exe from windows SDK, so either install full SDK or export mt.exe using those instructions
- main.c
#include <direct.h> #include <locale.h> #include <stdio.h> #include <windows.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { char codepage_message[50]; sprintf(codepage_message, "Codepage is %d", GetACP()); MessageBoxA(NULL, codepage_message, "ąęśćż", MB_ICONINFORMATION); // create directory called 😊 // setlocale might not be needed, but it is recommended setlocale(LC_ALL, ".UTF8"); _mkdir("😊"); return 0; }
- app.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyIdentity type="win32" name="YourApp" version="1.0.0.0"/> <application> <windowsSettings> <activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage> </windowsSettings> </application> </assembly>
gcc -finput-charset=utf-8 -fexec-charset=utf-8 main.c -o main.exe mt.exe -manifest app.manifest -outputresource:main.exe;#1
-finput-charset=utf-8 and -fexec-charset=utf-8 are optional since gcc usually parses and emits utf-8 strings by default (usually)
computer_tips/how_to_create_utf-8_winapi_application_using_mingw_toolchain.1784631992.txt.gz · Last modified: (external edit)
