programs/notepad: Load UTF-8 encoding name from resources instead of using GetCPInfoEx.

Alexander Scott-Johns alexander.scott.johns at googlemail.com
Fri Jan 28 10:28:14 CST 2011


Using GetCPInfoEx was a nice idea, but unfortunately its output is not
right on Windows nor non-English Wine.

For example, if the current language is (say) Russian,
 * On Windows, GetCPInfoEx(CP_UTF8, ...) returns "65001 (UTF-8)".
 * On Wine,    GetCPInfoEx(CP_UTF8, ...) returns "Unicode (UTF-8)".

But to be consistent with the other Unicode encodings in Notepad, it
needs to be "Юникод (UTF-8)".
-------------- next part --------------
From 0a99c7daca9f34303564156c4e049329ee3317b5 Mon Sep 17 00:00:00 2001
From: Alexander Scott-Johns <alexander.scott.johns at googlemail.com>
Date: Thu, 27 Jan 2011 20:08:22 +0000
Subject: notepad: Load UTF-8 encoding name from resources instead of using GetCPInfoEx.

---
 programs/notepad/dialog.c      |   12 ++++++++++--
 programs/notepad/notepad.rc    |    1 +
 programs/notepad/notepad_res.h |    3 ++-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/programs/notepad/dialog.c b/programs/notepad/dialog.c
index e9a650d..b4da7d0 100644
--- a/programs/notepad/dialog.c
+++ b/programs/notepad/dialog.c
@@ -58,13 +58,21 @@ static void load_encoding_name(ENCODING enc, WCHAR* buffer, int length)
             LoadStringW(Globals.hInstance, STRING_UNICODE_BE, buffer, length);
             break;
 
-        default:
+        case ENCODING_UTF8:
+            LoadStringW(Globals.hInstance, STRING_UTF8, buffer, length);
+            break;
+
+        case ENCODING_ANSI:
         {
             CPINFOEXW cpi;
-            GetCPInfoExW((enc==ENCODING_UTF8) ? CP_UTF8 : CP_ACP, 0, &cpi);
+            GetCPInfoExW(CP_ACP, 0, &cpi);
             lstrcpynW(buffer, cpi.CodePageName, length);
             break;
         }
+
+        default:
+            assert(0 && "bad encoding in load_encoding_name");
+            break;
     }
 }
 
diff --git a/programs/notepad/notepad.rc b/programs/notepad/notepad.rc
index 92667f4..e73a98e 100644
--- a/programs/notepad/notepad.rc
+++ b/programs/notepad/notepad.rc
@@ -92,6 +92,7 @@ task.\nClose one or more applications to increase the amount of free memory."
 
 STRING_UNICODE_LE,     "Unicode (UTF-16)"
 STRING_UNICODE_BE,     "Unicode (UTF-16 big-endian)"
+STRING_UTF8,           "Unicode (UTF-8)"
 
 STRING_LOSS_OF_UNICODE_CHARACTERS,         "%s\n\
 This file contains Unicode characters which will be lost if\n\
diff --git a/programs/notepad/notepad_res.h b/programs/notepad/notepad_res.h
index 5428c0d..553fa6d 100644
--- a/programs/notepad/notepad_res.h
+++ b/programs/notepad/notepad_res.h
@@ -87,8 +87,9 @@
 
 #define STRING_UNICODE_LE      0x180
 #define STRING_UNICODE_BE      0x181
+#define STRING_UTF8            0x182
 
-#define STRING_LOSS_OF_UNICODE_CHARACTERS 0x182
+#define STRING_LOSS_OF_UNICODE_CHARACTERS 0x183
 
 /* Open/Save As dialog template */
 #define IDD_OFN_TEMPLATE       0x190
-- 
1.7.0.4


More information about the wine-patches mailing list