From 0dd33ddc32b72b46bedceb5ceb477c27379692e6 Mon Sep 17 00:00:00 2001 From: Stas Degteff Date: Wed, 21 Feb 2007 13:47:10 +0000 Subject: [PATCH] get console charset in Win32 --- goldlib/gall/gcharset.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/goldlib/gall/gcharset.cpp b/goldlib/gall/gcharset.cpp index 11fcd4f..5f46456 100644 --- a/goldlib/gall/gcharset.cpp +++ b/goldlib/gall/gcharset.cpp @@ -99,9 +99,14 @@ const char *get_charset(void) const char *get_dos_charset(const char *cpfrom) { -#if defined(__WIN32__) || defined(__MSDOS__) || defined(__OS2__) +#if defined(__WIN32__) + int cp = GetOEMCP(); + static char cpto[10]=""; + if (cp) snprintf(cpto, sizeof(cpto), "CP%u", cp); + else cpto[0]='\0'; + return cpto; +#elif defined(__MSDOS__) || defined(__OS2__) (void)cpfrom; // These platforms use DOS CP on console, so ignore request - // Another way is possible in Windows: get charset using GetANSICP() return ""; #else static const struct _cpmap {