public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Costas Argyris <costas.argyris@gmail.com>
To: binutils@sourceware.org
Subject: [PATCH] mingw-host: Insert resource to enable UTF-8 active code page.
Date: Sun, 25 Jun 2023 22:04:34 +0100	[thread overview]
Message-ID: <CAHyHGC=kdJMR-b3UAB59YMm4HrBXC6Eo7ZyteA+o7scE2VNh4A@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 319 bytes --]

When running in mingw host as Windows processes, the active code page used
today is the locale-specific codepage, which is not Unicode.

This patch builds the utf8 resource object file using windres and adds it
to LDFLAGS for mingw host, which makes all built executables use utf8
(65001 windows code page identifier).

[-- Attachment #2: 0001-mingw-host-Insert-resource-to-enable-UTF-8-active-co.patch --]
[-- Type: application/octet-stream, Size: 1849 bytes --]

From d2ece2affe3b0daa4641ece6068d7082df093bc3 Mon Sep 17 00:00:00 2001
From: Costas Argyris <costas.argyris@gmail.com>
Date: Sun, 25 Jun 2023 21:23:59 +0100
Subject: [PATCH] mingw-host: Insert resource to enable UTF-8 active code page.

---
 config/mh-mingw            | 6 ++++++
 config/utf8-mingw.manifest | 8 ++++++++
 config/utf8-mingw.rc       | 3 +++
 3 files changed, 17 insertions(+)
 create mode 100644 config/utf8-mingw.manifest
 create mode 100644 config/utf8-mingw.rc

diff --git a/config/mh-mingw b/config/mh-mingw
index a795096f038..c02a6ccb1be 100644
--- a/config/mh-mingw
+++ b/config/mh-mingw
@@ -11,3 +11,9 @@ STAGE4_CXXFLAGS += -D__USE_MINGW_ACCESS
 # as GCC turns out to need that much more to pass all the limits-* tests.
 LDFLAGS += -Wl,--stack,12582912
 BOOT_LDFLAGS += -Wl,--stack,12582912
+
+# UTF-8 resource object
+UTF8RES := `$(WINDRES) $(srcdir)/config/utf8-mingw.rc $$r/utf8res.o \
+&& echo $$r/utf8res.o`
+
+LDFLAGS += -Wl,$(UTF8RES)
\ No newline at end of file
diff --git a/config/utf8-mingw.manifest b/config/utf8-mingw.manifest
new file mode 100644
index 00000000000..0dff8970043
--- /dev/null
+++ b/config/utf8-mingw.manifest
@@ -0,0 +1,8 @@
+<?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>
\ No newline at end of file
diff --git a/config/utf8-mingw.rc b/config/utf8-mingw.rc
new file mode 100644
index 00000000000..96c7237c6bc
--- /dev/null
+++ b/config/utf8-mingw.rc
@@ -0,0 +1,3 @@
+#include <winuser.h>
+
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "utf8-mingw.manifest"
\ No newline at end of file
-- 
2.41.0


                 reply	other threads:[~2023-06-25 21:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHyHGC=kdJMR-b3UAB59YMm4HrBXC6Eo7ZyteA+o7scE2VNh4A@mail.gmail.com' \
    --to=costas.argyris@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).