From 194870fe5e030446a52235a24f9060b0f4bcb410 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 27 Sep 2019 19:34:32 +0200 Subject: [PATCH] Recognize system UTF-8 encoding under MSW too Recent versions of Windows 10 (finally!) allow to set up UTF-8 as the system encoding, so recognize when it is returned by GetACP() in wxLocale::GetSystemEncoding() and GetSystemEncodingName(). --- src/common/intl.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 150fa2de06..8fbd6b00ed 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -825,8 +825,16 @@ wxString wxLocale::GetSystemEncodingName() #if defined(__WIN32__) // FIXME: what is the error return value for GetACP()? - UINT codepage = ::GetACP(); - encname.Printf(wxS("windows-%u"), codepage); + const UINT codepage = ::GetACP(); + switch ( codepage ) + { + case 65001: + encname = "UTF-8"; + break; + + default: + encname.Printf(wxS("windows-%u"), codepage); + } #elif defined(__WXMAC__) encname = wxCFStringRef::AsString( CFStringGetNameOfEncoding(CFStringGetSystemEncoding()) @@ -909,6 +917,9 @@ wxFontEncoding wxLocale::GetSystemEncoding() case 950: return wxFONTENCODING_CP950; + + case 65001: + return wxFONTENCODING_UTF8; } #elif defined(__WXMAC__) CFStringEncoding encoding = 0 ;