Attachment "0001-Support-utf-8-on-Windows-console.patch" to
ticket [0b9332722a]
added by
anonymous
2020-01-11 21:20:04.
From a6f077d151624ed83ca8b8e2753c34f287369f16 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Old=C5=99ich=20Jedli=C4=8Dka?= <[email protected]>
Date: Sat, 11 Jan 2020 20:35:57 +0100
Subject: [PATCH] Support utf-8 on Windows console.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When UTF-8 feature is enabled in Windows, the console reports code page
65001. This is an official code page value with constant CP_UTF8, but this
code page is not recognised by Tcl. Fix this by reporting utf-8 instead of
cp65001.
Signed-off-by: Oldřich Jedlička <[email protected]>
---
win/tclWinInit.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 1f03b1d85..ab19fa772 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -454,10 +454,19 @@ const char *
Tcl_GetEncodingNameFromEnvironment(
Tcl_DString *bufPtr)
{
+ UINT acp;
+
Tcl_DStringInit(bufPtr);
- Tcl_DStringSetLength(bufPtr, 2+TCL_INTEGER_SPACE);
- wsprintfA(Tcl_DStringValue(bufPtr), "cp%d", GetACP());
- Tcl_DStringSetLength(bufPtr, strlen(Tcl_DStringValue(bufPtr)));
+
+ acp = GetACP();
+ if (acp == CP_UTF8) {
+ Tcl_DStringAppend(bufPtr, "utf-8", 5U);
+ } else {
+ Tcl_DStringSetLength(bufPtr, 2 + TCL_INTEGER_SPACE);
+ wsprintfA(Tcl_DStringValue(bufPtr), "cp%d", acp);
+ Tcl_DStringSetLength(bufPtr, strlen(Tcl_DStringValue(bufPtr)));
+ }
+
return Tcl_DStringValue(bufPtr);
}
--
2.25.0.rc2.windows.1