From f58eed36ffabd530ccafee08dbdc18b1f235a172 Mon Sep 17 00:00:00 2001 From: Vijay Kiran Kamuju Date: Mon, 11 Jul 2005 14:21:53 +0000 Subject: [PATCH] Fix _setmbcp behavior for unreal codepages. --- dlls/msvcrt/locale.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c index 94ddd712785..a7199a8ba2b 100644 --- a/dlls/msvcrt/locale.c +++ b/dlls/msvcrt/locale.c @@ -31,6 +31,7 @@ #include "msvcrt.h" #include "mtdll.h" +#include "msvcrt/mbctype.h" #include "wine/debug.h" @@ -517,17 +518,33 @@ const char* _Strftime(char *out, unsigned int len, const char *fmt, */ int _setmbcp(int cp) { - if (cp < 0) - { - FIXME ("Unreal codepages (e.g. %d) not implemented\n", cp); - return 0; /* Let's not confuse the caller by returning -1 */ - } LOCK_LOCALE; - if (msvcrt_current_lc_all_cp != cp) + if ((msvcrt_current_lc_all_cp != cp) && (cp > _MB_CP_SBCS)) { /* FIXME: set ctype behaviour for this cp */ msvcrt_current_lc_all_cp = cp; } + else if(cp == _MB_CP_ANSI) + { + msvcrt_current_lc_all_cp = GetACP(); + } + else if(cp == _MB_CP_OEM) + { + msvcrt_current_lc_all_cp = GetOEMCP(); + } + else if(cp == _MB_CP_LOCALE) + { + GetLocaleInfoW( GetUserDefaultLCID(), LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER, + (WCHAR *)&msvcrt_current_lc_all_cp, sizeof(INT)/sizeof(WCHAR) ); + } + else if(cp == _MB_CP_SBCS) + { + FIXME ("SBCS codepages (e.g. %d) not implemented\n", cp); + } + else + { + FIXME ("Unreal codepages (e.g. %d) not implemented\n", cp); + } UNLOCK_LOCALE; return 0; }