https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108865

--- Comment #4 from Costas Argyris <costas.argyris at gmail dot com> ---
Using the manifest approach described in:

https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page

it is possible to convert a full existing gcc + mingw-w64 toolchain (all
executables) to use UTF-8 as their active code page.

The proper solution would be to integrate the UTF-8 manifest into gcc's own
build process.    Until that happens, and to enable existing installations to
work with Unicode paths, this is the procedure to convert an existing gcc
(mingw-w64) installation on Windows to use the UTF-8 code page.

Requirements:

1) See above link to check if your version of Windows supports this.
2) You must have the manifest tool mt.exe installed and know its location.
3) Go to a temp dir and create a 'utf8_acp_setting.manifest' file with this
content:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <application>
    <windowsSettings>
      <activeCodePage
xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings";>UTF-8</activeCodePage>
    </windowsSettings>
  </application>
</assembly>

Assume that the current installation is at C:\mingw64.    We are going to
create a copy of it in C:\mingw64-UTF8 and apply the UTF-8 manifest in every
executable using mt.exe.

Add the folder of mt.exe to the path, for example

set PATH=C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;%PATH%

('where mt' should find it)

Copy the entire C:\mingw64 directory to C:\mingw64-UTF8 from the UI or using

robocopy C:\mingw64 C:\mingw64-UTF8 /e

Cd into the folder where utf8_acp_setting.manifest is and run:

for /F %f in ('dir /B /S C:\mingw64-UTF8\*.exe') do mt "-outputresource:%f;1"
-manifest "utf8_acp_setting.manifest"

After this, the toolchain under C:\mingw64-UTF8 should be able to compile the
file that was previously failing.

Make sure that you add C:\mingw64-UTF8\bin to the path instead of
C:\mingw64\bin

set PATH=C:\mingw64-UTF8\bin;%PATH%

and check with 'where gcc' - it should return the one under C:\mingw64-UTF8\bin

Now compile the file in the Unicode path that was previously failing:

C:\Users\cargyris\temp>gcc ﹏\src.c

C:\Users\cargyris\temp>echo %errorlevel%
0

no errors this time.

Reply via email to